mirror of
https://github.com/bitnami/containers.git
synced 2026-10-17 21:50:48 +02:00
* see #86: add support for reverse proxy headers Signed-off-by: David Riccitelli <david@wordlift.io> Co-authored-by: Bitnami Bot <bitnami-bot@vmware.com> Co-authored-by: Carlos Rodriguez Hernandez <carlosrh@vmware.com>
This commit is contained in:
committed by
Bitnami Containers
co-authored by
Bitnami Bot
Carlos Rodriguez Hernandez
parent
9b0c2d6d2d
commit
dadb907f22
@@ -89,6 +89,7 @@ wordpress_validate() {
|
||||
check_yes_no_value "WORDPRESS_RESET_DATA_PERMISSIONS"
|
||||
check_yes_no_value "WORDPRESS_SKIP_BOOTSTRAP"
|
||||
check_multi_value "WORDPRESS_AUTO_UPDATE_LEVEL" "major minor none"
|
||||
check_yes_no_value "WORDPRESS_ENABLE_REVERSE_PROXY"
|
||||
|
||||
# Multisite validations
|
||||
check_yes_no_value "WORDPRESS_ENABLE_MULTISITE"
|
||||
@@ -243,6 +244,7 @@ wordpress_initialize() {
|
||||
if is_file_writable "$WORDPRESS_CONF_FILE"; then
|
||||
# Set miscellaneous configurations
|
||||
wordpress_conf_set "FS_METHOD" "direct"
|
||||
is_boolean_yes "$WORDPRESS_ENABLE_REVERSE_PROXY" && wordpress_configure_reverse_proxy
|
||||
! is_boolean_yes "$WORDPRESS_ENABLE_MULTISITE" && wordpress_configure_urls
|
||||
# The only variable/non-constant in the entire configuration file is '$table_prefix'
|
||||
replace_in_file "$WORDPRESS_CONF_FILE" "^(\s*\\\$table_prefix\s*=\s*).*" "\1'$WORDPRESS_TABLE_PREFIX';"
|
||||
@@ -606,6 +608,35 @@ if ( !defined( 'WP_CLI' ) ) {
|
||||
EOF
|
||||
}
|
||||
|
||||
########################
|
||||
# Configure reverse proxy headers
|
||||
# Globals:
|
||||
# *
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
wordpress_configure_reverse_proxy() {
|
||||
wordpress_conf_append "$(
|
||||
cat <<"EOF"
|
||||
|
||||
/**
|
||||
* Handle potential reverse proxy headers. Ref:
|
||||
* - https://wordpress.org/support/article/faq-installation/#how-can-i-get-wordpress-working-when-im-behind-a-reverse-proxy
|
||||
* - https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
|
||||
*/
|
||||
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
|
||||
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
|
||||
}
|
||||
|
||||
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) \&\& 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
}
|
||||
EOF
|
||||
)"
|
||||
}
|
||||
|
||||
########################
|
||||
# Configure application URLs for WordPress (non-Multisite)
|
||||
# Globals:
|
||||
@@ -620,6 +651,7 @@ wordpress_configure_urls() {
|
||||
# Note that wp-config.php is officially indented via tabs, not spaces
|
||||
wordpress_conf_append "$(
|
||||
cat <<"EOF"
|
||||
|
||||
/**
|
||||
* The WP_SITEURL and WP_HOME options are configured to access from any hostname or IP address.
|
||||
* If you want to access only from an specific domain, you can modify them. For example:
|
||||
|
||||
@@ -50,6 +50,7 @@ wordpress_env_vars=(
|
||||
WORDPRESS_FIRST_NAME
|
||||
WORDPRESS_LAST_NAME
|
||||
WORDPRESS_ENABLE_MULTISITE
|
||||
WORDPRESS_ENABLE_REVERSE_PROXY
|
||||
WORDPRESS_MULTISITE_NETWORK_TYPE
|
||||
WORDPRESS_MULTISITE_EXTERNAL_HTTP_PORT_NUMBER
|
||||
WORDPRESS_MULTISITE_EXTERNAL_HTTPS_PORT_NUMBER
|
||||
@@ -135,6 +136,7 @@ export WORDPRESS_AUTH_SALT="${WORDPRESS_AUTH_SALT:-}"
|
||||
export WORDPRESS_SECURE_AUTH_SALT="${WORDPRESS_SECURE_AUTH_SALT:-}"
|
||||
export WORDPRESS_LOGGED_IN_SALT="${WORDPRESS_LOGGED_IN_SALT:-}"
|
||||
export WORDPRESS_NONCE_SALT="${WORDPRESS_NONCE_SALT:-}"
|
||||
export WORDPRESS_ENABLE_REVERSE_PROXY="${WORDPRESS_ENABLE_REVERSE_PROXY:-no}" # only used during the first initialization
|
||||
|
||||
# WordPress credentials
|
||||
export WORDPRESS_USERNAME="${WORDPRESS_USERNAME:-user}" # only used during the first initialization
|
||||
|
||||
@@ -248,6 +248,7 @@ Available environment variables:
|
||||
- `WORDPRESS_MULTISITE_NETWORK_TYPE`: WordPress Multisite network type to enable. Valid values: `subfolder`, `subdirectory`, `subdomain`. Default: **subdomain**
|
||||
- `WORDPRESS_MULTISITE_ENABLE_NIP_IO_REDIRECTION`: Whether to enable IP address redirection to nip.io wildcard DNS when enabling WordPress Multisite. This is useful when running on an IP address with subdomain network type. Default: **no**
|
||||
- `WORDPRESS_MULTISITE_FILEUPLOAD_MAXK`: Maximum upload file size allowed for WordPress Multisite uploads, in kilobytes. Default: **81920**
|
||||
- `WORDPRESS_ENABLE_REVERSE_PROXY`: Enable WordPress support for reverse proxy headers. Default: **no**
|
||||
|
||||
##### Database connection configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user