mirror of
https://github.com/bitnami/containers.git
synced 2026-02-20 14:57:23 +08:00
[bitnami/mediawiki] improve configuration for reverse proxy configs (#64098)
* [bitnami/mediawiki] write server conf at runtime instead of build we need the `RewriteRule` in the vhost to match `wgArticlePath` in the application `LocalSettings.php`, which requires that it be modified at startup in order to respect custom values of `MEDIAWIKI_WIKI_PREFIX`. Signed-off-by: alexandra catalina <git@garbage.world> * [bitnami/mediawiki] rm unused web_server_update_app_configuration Signed-off-by: alexandra catalina <git@garbage.world> * [bitnami/mediawiki] add MEDIAWIKI_SCRIPT_PATH Signed-off-by: alexandra catalina <git@garbage.world> * [bitnami/mediawiki] use MEDIAWIKI_HOST for canonical, not wgServer setting $wgServer to the hostname results in all generated links using that host, instead of being relative URLs. this breaks deployments run behind a reverse proxy if the proxy port/path differs from MediaWiki's. Signed-off-by: alexandra catalina <git@garbage.world> * Revert "[bitnami/mediawiki] rm unused web_server_update_app_configuration" This reverts commit bc404152d8797caed24c9933a2131272f3b7ab3a. Signed-off-by: alexandra catalina <git@garbage.world> * [bitnami/mediawiki] add back web_server_update_app_configuration Signed-off-by: alexandra catalina <git@garbage.world> * [bitnami/mediawiki] remove vhost test this file is now generated at run-time Signed-off-by: alexandra catalina <git@garbage.world> * [bitnami/mediawiki] default MEDIAWIKI_SCRIPT_PATH to `/` That matches the current behavior and avoids breaking existing installations Signed-off-by: alexandra catalina <git@garbage.world> --------- Signed-off-by: alexandra catalina <git@garbage.world>
This commit is contained in:
committed by
GitHub
parent
749762270f
commit
293b3c32e4
@@ -37,12 +37,6 @@ file:
|
||||
filetype: file
|
||||
contents:
|
||||
- "memory_limit = 256M"
|
||||
/opt/bitnami/apache/conf/vhosts/mediawiki-vhost.conf:
|
||||
exists: true
|
||||
filetype: file
|
||||
contents:
|
||||
- "RewriteEngine On"
|
||||
- "RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]"
|
||||
/opt/bitnami/mediawiki/extensions/Scribunto:
|
||||
exists: false
|
||||
command:
|
||||
|
||||
@@ -137,9 +137,14 @@ mediawiki_initialize() {
|
||||
mediawiki_configure_short_urls
|
||||
mediawiki_conf_set "\$wgEnableUploads" "true" yes
|
||||
which convert >/dev/null && mediawiki_conf_set "\$wgUseImageMagick" "true" yes
|
||||
|
||||
mediawiki_configure_host "$MEDIAWIKI_HOST"
|
||||
mediawiki_conf_set "\$wgEmergencyContact" "$MEDIAWIKI_EMAIL"
|
||||
mediawiki_conf_set "\$wgPasswordSender" "$MEDIAWIKI_EMAIL"
|
||||
# this key isn't included in the default LocalSettings
|
||||
cat >> "$MEDIAWIKI_CONF_FILE" <<EOF
|
||||
\$wgAssumeProxiesUseDefaultProtocolPorts = false;
|
||||
EOF
|
||||
mediawiki_configure_smtp
|
||||
|
||||
info "Persisting MediaWiki installation"
|
||||
@@ -299,7 +304,7 @@ EOF
|
||||
#########################
|
||||
mediawiki_configure_short_urls() {
|
||||
info "Setting MediaWiki short URLs"
|
||||
mediawiki_conf_set "\$wgScriptPath" ""
|
||||
mediawiki_conf_set "\$wgScriptPath" "$MEDIAWIKI_SCRIPT_PATH"
|
||||
cat >>"$MEDIAWIKI_CONF_FILE" <<EOF
|
||||
\$wgArticlePath = "$MEDIAWIKI_WIKI_PREFIX/\$1";
|
||||
\$wgUsePathInfo = true;
|
||||
@@ -323,14 +328,14 @@ mediawiki_configure_host() {
|
||||
url="https://${host}"
|
||||
[[ "$MEDIAWIKI_EXTERNAL_HTTPS_PORT_NUMBER" != "443" ]] && url+=":${MEDIAWIKI_EXTERNAL_HTTPS_PORT_NUMBER}"
|
||||
else
|
||||
if [[ "$MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER" != "80" || "$MEDIAWIKI_EXTERNAL_HTTPS_PORT_NUMBER" != "443" ]]; then
|
||||
url="http://${host}"
|
||||
[[ "$MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER" != "80" ]] && url+=":${MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER}"
|
||||
else
|
||||
# If using default values, support both HTTP and HTTPS at the same time
|
||||
url="//${host}"
|
||||
fi
|
||||
url="http://${host}"
|
||||
[[ "$MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER" != "80" ]] && url+=":${MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER}"
|
||||
fi
|
||||
mediawiki_conf_set "\$wgServer" "$url"
|
||||
|
||||
mediawiki_conf_set "\$wgServer" ""
|
||||
# these keys aren't included in the default LocalSettings
|
||||
cat >> "$MEDIAWIKI_CONF_FILE" <<EOF
|
||||
\$wgCanonicalServer = "$url";
|
||||
\$wgEnableCanonicalServerLink = true;
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ mediawiki_env_vars=(
|
||||
MEDIAWIKI_SKIP_BOOTSTRAP
|
||||
MEDIAWIKI_WIKI_NAME
|
||||
MEDIAWIKI_WIKI_PREFIX
|
||||
MEDIAWIKI_SCRIPT_PATH
|
||||
MEDIAWIKI_HOST
|
||||
MEDIAWIKI_ENABLE_HTTPS
|
||||
MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER
|
||||
@@ -82,6 +83,7 @@ export MEDIAWIKI_DATA_TO_PERSIST="${MEDIAWIKI_DATA_TO_PERSIST:-images extensions
|
||||
export MEDIAWIKI_SKIP_BOOTSTRAP="${MEDIAWIKI_SKIP_BOOTSTRAP:-}" # only used during the first initialization
|
||||
export MEDIAWIKI_WIKI_NAME="${MEDIAWIKI_WIKI_NAME:-Bitnami MediaWiki}" # only used during the first initialization
|
||||
export MEDIAWIKI_WIKI_PREFIX="${MEDIAWIKI_WIKI_PREFIX:-/wiki}" # only used during the first initialization
|
||||
export MEDIAWIKI_SCRIPT_PATH="${MEDIAWIKI_SCRIPT_PATH:-/}" # only used during the first initialization
|
||||
export MEDIAWIKI_HOST="${MEDIAWIKI_HOST:-localhost}" # only used during the first initialization
|
||||
export MEDIAWIKI_ENABLE_HTTPS="${MEDIAWIKI_ENABLE_HTTPS:-no}" # only used during the first initialization
|
||||
export MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER="${MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER:-80}" # only used during the first initialization
|
||||
|
||||
@@ -45,10 +45,6 @@ pear install mail net_smtp
|
||||
# Enable default web server configuration for MediaWiki
|
||||
info "Creating default web server configuration for MediaWiki"
|
||||
web_server_validate
|
||||
ensure_web_server_app_configuration_exists "mediawiki" --type php --apache-extra-directory-configuration "
|
||||
RewriteEngine On
|
||||
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]
|
||||
"
|
||||
|
||||
# Copy all initially generated configuration files to the default directory
|
||||
# (this is to avoid breaking when entrypoint is being overridden)
|
||||
|
||||
@@ -32,6 +32,12 @@ fi
|
||||
mediawiki_validate
|
||||
|
||||
# Update web server configuration with runtime environment (needs to happen before the initialization)
|
||||
ensure_web_server_app_configuration_exists "mediawiki" --type php --apache-extra-directory-configuration "
|
||||
RewriteEngine On
|
||||
RewriteRule ^/?${MEDIAWIKI_WIKI_PREFIX:1}(/.*)?$ %{DOCUMENT_ROOT}/index.php
|
||||
RewriteRule ^/?${MEDIAWIKI_SCRIPT_PATH:1}(.*)$ %{DOCUMENT_ROOT}/\$1 [L]
|
||||
"
|
||||
|
||||
web_server_update_app_configuration "mediawiki"
|
||||
|
||||
# Ensure MediaWiki is initialized
|
||||
|
||||
@@ -204,7 +204,8 @@ docker run -d --name mediawiki \
|
||||
| `MEDIAWIKI_SKIP_BOOTSTRAP` | Whether to perform initial bootstrapping for the application. | `nil` |
|
||||
| `MEDIAWIKI_WIKI_NAME` | MediaWiki wiki name. | `Bitnami MediaWiki` |
|
||||
| `MEDIAWIKI_WIKI_PREFIX` | Base path to use for MediaWiki wiki URLs. | `/wiki` |
|
||||
| `MEDIAWIKI_HOST` | MediaWiki application host. | `localhost` |
|
||||
| `MEDIAWIKI_SCRIPT_PATH` | Base path to use for MediaWiki script URLs. | `"/"` |
|
||||
| `MEDIAWIKI_HOST` | MediaWiki application host, used to set the canonical URL. | `localhost` |
|
||||
| `MEDIAWIKI_ENABLE_HTTPS` | Whether to use HTTPS by default. | `no` |
|
||||
| `MEDIAWIKI_EXTERNAL_HTTP_PORT_NUMBER` | Port to used by MediaWiki to generate URLs and links when accessing using HTTP. | `80` |
|
||||
| `MEDIAWIKI_EXTERNAL_HTTPS_PORT_NUMBER` | Port to used by MediaWiki to generate URLs and links when accessing using HTTPS. | `443` |
|
||||
|
||||
Reference in New Issue
Block a user