Skip to content

Commit

Permalink
[bitnami/mediawiki] use MEDIAWIKI_HOST for canonical, not wgServer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dunn committed Apr 2, 2024
1 parent df22dd7 commit 1112ae3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,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"
Expand Down Expand Up @@ -317,14 +322,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
}
2 changes: 1 addition & 1 deletion bitnami/mediawiki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ docker run -d --name mediawiki \
| `MEDIAWIKI_WIKI_NAME` | MediaWiki wiki name. | `Bitnami MediaWiki` |
| `MEDIAWIKI_WIKI_PREFIX` | Base path to use for MediaWiki wiki URLs. | `/wiki` |
| `MEDIAWIKI_SCRIPT_PATH` | Base path to use for MediaWiki script URLs. | `"/w"` |
| `MEDIAWIKI_HOST` | MediaWiki application host. | `localhost` |
| `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` |
Expand Down

0 comments on commit 1112ae3

Please sign in to comment.