Search code examples
nginxsubdomainmediawikireverse-proxysubdirectory

MediaWiki installed with nginx reverse proxy configuration


I would like to install MediaWiki in such a way.

  1. Download and extract all the MediaWiki installation files to a location where wiki.gaobo.org nginx server block points to;
  2. Set up a reverse proxy configuration in gao.bo nginx server block so that gao.bo/wiki is equivalent to wiki.gaobo.org ;
  3. Launch the installation from gao.bo/wiki so that initially the server URL is gao.bo/wiki instead of wiki.gaobo.org .

Questions:

  1. Is the design above implementable after all?
  2. If possible, how to implement Step 2?

Solution

  • This is certainly doable (although from a generic usability and information security point of view having different things on different domains is usually better). Probably the easiest way to do it is to not expose the MediaWiki server directly to the web, install MediaWiki under /wiki and tell it (via $wgServer) that it is running on gao.bo. That way the proxy does not have to deal with URL rewrites, cookie path rewrites, different domain names etc.

    To set that up, you would set something like

    location /wiki/ {
        proxy_pass http://<IP of your MediaWiki server>;
    }
    

    for the proxy nginx, and make sure the wiki server routes requests for /wiki/ to the MediaWiki installation. Then you can just run the installer via the proxy, as you described, and add the IP of the proxy to $wgSquidServers so that MediaWiki trusts X-Forwarded-For headers.