<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AVhost_-_RProxy_settings</id>
	<title>ICT:Vhost - RProxy settings - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AVhost_-_RProxy_settings"/>
	<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:Vhost_-_RProxy_settings&amp;action=history"/>
	<updated>2026-07-22T23:27:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://mwiki.costasano.club/index.php?title=ICT:Vhost_-_RProxy_settings&amp;diff=7&amp;oldid=prev</id>
		<title>Mngr: Nieuwe pagina aangemaakt met &#039; = 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:  * &lt;code&gt;load.php&lt;/code&gt; * &lt;code&gt;api.php&lt;/code&gt; * &lt;code&gt;rest.php&lt;/code&gt;  These must &#039;&#039;&#039;never&#039;&#039;&#039; be rewritten to &lt;code&gt;index.php&lt;/code&gt;.   If they are rewritten, MediaWiki returns HTML instead of JS…&#039;</title>
		<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:Vhost_-_RProxy_settings&amp;diff=7&amp;oldid=prev"/>
		<updated>2025-12-26T16:37:23Z</updated>

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