ICT:Vhost - RProxy settings
MediaWiki Ingress Summary
This page documents how requests flow from IIS → Apache → MediaWiki, and what must be configured to keep the wiki stable, predictable, and successor‑friendly.
1. Overview
MediaWiki depends on three critical entry points:
load.phpapi.phprest.php
These must never be rewritten to index.php.
If they are rewritten, MediaWiki returns HTML instead of JSON/JS, and the entire layout breaks.
Correct ingress requires:
- the correct Apache vhost
- the correct rewrite exceptions
- the correct PHP-FPM handler
- IIS forwarding the original Host header
2. Vhost Selection Logic
Apache chooses a vhost based on the Host header forwarded by IIS.
- Requests with
Host: localhosthit the default vhost - Requests with
Host: mwiki.costasano.clubhit the named vhost
If the wrong vhost handles the request, MediaWiki breaks even if the files and PHP are correct.
3. Required vhost configuration
<VirtualHost *:80>
ServerName mwiki.costasano.club
DocumentRoot /var/www/mediawiki
<Directory /var/www/mediawiki>
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost/"
</FilesMatch>
</VirtualHost>
This ensures:
- the correct document root
- PHP-FPM execution
.htaccesssupport- correct vhost selection
4. Required rewrite exceptions
These rules prevent MediaWiki’s core entry points from being rewritten to index.php.
# Do NOT rewrite REST entry point
RewriteCond %{REQUEST_URI} ^/rest\.php
RewriteRule .* - [L]
# Do NOT rewrite API entry point
RewriteCond %{REQUEST_URI} ^/api\.php
RewriteRule .* - [L]
# Do NOT rewrite ResourceLoader entry point
RewriteCond %{REQUEST_URI} ^/load\.php
RewriteRule .* - [L]
These rules:
- work in vhost context
- work in per‑directory context
- work with query strings
- prevent accidental rewrites
- ensure PHP-FPM executes the scripts directly
5. Catch‑all rewrite rule
Everything else can be rewritten to index.php:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]
This is the standard MediaWiki behavior.
6. How to diagnose layout failures
If the layout breaks, test:
curl -I -H "Host: mwiki.costasano.club" http://localhost/load.php
Expected result:
200 OKContent-Type: text/javascript
If you get HTML or a 404, the issue is:
- wrong vhost
- wrong rewrite rule
- PHP-FPM not invoked
7. Key Lessons
- Everything depends on which vhost handles the request.
- Rewrite rules behave differently in vhost vs per‑directory mode.
- MediaWiki’s entry points must be explicitly protected.
- IIS is not the problem if Apache receives the wrong Host header.
- Once vhost + rewrite rules are correct, the wiki becomes stable and predictable.