Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/mediawiki] improve configuration for reverse proxy configs #64098

Merged
merged 8 commits into from May 21, 2024

Conversation

dunn
Copy link
Contributor

@dunn dunn commented Mar 24, 2024

several changes to improve behavior when running behind a reverse proxy:

  • 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.
  • setting $wgScriptPath to "" is fine for the normal case, but if you're running behind a reverse proxy and want to serve MediaWiki on one path (e.g., /wiki) and other services on other paths, being able to set the script path as non-root makes proxy routing easier.
  • setting $wgServer to MEDIAWIKI_HOST results in absolute URLs including the full hostname and port, instead of relative URLs, which breaks links when the reverse proxy is running on a different port. for the same reason, set $wgAssumeProxiesUseDefaultProtocolPorts to false.

Fixes #64097

@github-actions github-actions bot added mediawiki triage Triage is needed labels Mar 24, 2024
@github-actions github-actions bot requested a review from carrodher March 24, 2024 00:32
@carrodher carrodher added verify Execute verification workflow for these changes in-progress labels Mar 24, 2024
@github-actions github-actions bot removed the triage Triage is needed label Mar 24, 2024
@github-actions github-actions bot removed the request for review from carrodher March 24, 2024 12:22
@github-actions github-actions bot requested a review from fevisera March 24, 2024 12:22
@dunn
Copy link
Contributor Author

dunn commented Apr 2, 2024

added a few commits, i was going to make separate PRs but these changes depend on each other. i'll update the PR description.

@dunn dunn force-pushed the mediawiki-rewriterule branch 2 times, most recently from dae774b to b550856 Compare April 2, 2024 20:05
@dunn dunn changed the title [bitnami/mediawiki] write server conf at runtime instead of build [bitnami/mediawiki] improve configuration for reverse proxy configs Apr 2, 2024
@dunn
Copy link
Contributor Author

dunn commented Apr 15, 2024

anything i can do to help move this forward?

Copy link
Member

@migruiz4 migruiz4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @dunn!

I have added several comments, please take a look at them.

Additionally, I would appreciate if you could remove the following section from the tests:

/opt/bitnami/apache/conf/vhosts/mediawiki-vhost.conf:
exists: true
filetype: file
contents:
- "RewriteEngine On"
- "RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]"

Because you are moving the Apache config creation from buildtime to runtime, the file no longer exists, causing the tests (and the CI/CD pipeline) to fail.

@dunn dunn force-pushed the mediawiki-rewriterule branch 2 times, most recently from b75418e to 3258375 Compare April 26, 2024 19:05
Copy link
Member

@migruiz4 migruiz4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dunn,

Thank you for implementing my suggestions, please take a look at my comment regarding MEDIAWIKI_SCRIPT_PATH.

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>
dunn added 7 commits May 12, 2024 12:32
Signed-off-by: alexandra catalina <git@garbage.world>
Signed-off-by: alexandra catalina <git@garbage.world>
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>
…tion"

This reverts commit bc40415.

Signed-off-by: alexandra catalina <git@garbage.world>
Signed-off-by: alexandra catalina <git@garbage.world>
this file is now generated at run-time

Signed-off-by: alexandra catalina <git@garbage.world>
That matches the current behavior and avoids breaking existing installations

Signed-off-by: alexandra catalina <git@garbage.world>
@dunn
Copy link
Contributor Author

dunn commented May 12, 2024

@migruiz4 thanks for the review! I added a commit setting MEDIAWIKI_SCRIPT_PATH to / by default, restoring the existing behavior.

Copy link
Member

@migruiz4 migruiz4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your contribution @dunn, looks good to me!

@migruiz4 migruiz4 merged commit 293b3c3 into bitnami:main May 21, 2024
11 checks passed
@dunn dunn deleted the mediawiki-rewriterule branch May 21, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mediawiki solved verify Execute verification workflow for these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bitnami/mediawiki] 404 errors when overriding MEDIAWIKI_WIKI_PREFIX
4 participants