From 75081c63ee8b204a239572a232d50455556882f4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 21 Mar 2016 01:55:24 -0400 Subject: Go ahead and add the generated files. So I know about regressions. --- public/nginx-mediawiki.html | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 public/nginx-mediawiki.html (limited to 'public/nginx-mediawiki.html') diff --git a/public/nginx-mediawiki.html b/public/nginx-mediawiki.html new file mode 100644 index 0000000..cd3cddb --- /dev/null +++ b/public/nginx-mediawiki.html @@ -0,0 +1,56 @@ + + + + + An Nginx configuration for MediaWiki — Luke Shumaker + + + +
Luke Shumaker » blog » nginx-mediawiki
+
+

An Nginx configuration for MediaWiki

+

There are several example Nginx configurations for MediaWiki floating around the web. Many of them don't block the user from accessing things like /serialized/. Many of them also don't correctly handle a wiki page named FAQ, since that is a name of a file in the MediaWiki root! In fact, the configuration used on the official Nginx Wiki has both of those issues!

+

This is because most of the configurations floating around basically try to pass all requests through, and blacklist certain requests, either denying them, or passing them through to index.php.

+

It's my view that blacklisting is inferior to whitelisting in situations like this. So, I developed the following configuration that instead works by whitelisting certain paths.

+
root /path/to/your/mediawiki; # obviously, change this line
+
+index index.php;
+location /                     { try_files /var/empty @rewrite; }
+location /images/              { try_files $uri $uri/ @rewrite; }
+location /skins/               { try_files $uri $uri/ @rewrite; }
+location /api.php              { try_files /var/empty @php; }
+location /api.php5             { try_files /var/empty @php; }
+location /img_auth.php         { try_files /var/empty @php; }
+location /img_auth.php5        { try_files /var/empty @php; }
+location /index.php            { try_files /var/empty @php; }
+location /index.php5           { try_files /var/empty @php; }
+location /load.php             { try_files /var/empty @php; }
+location /load.php5            { try_files /var/empty @php; }
+location /opensearch_desc.php  { try_files /var/empty @php; }
+location /opensearch_desc.php5 { try_files /var/empty @php; }
+location /profileinfo.php      { try_files /var/empty @php; }
+location /thumb.php            { try_files /var/empty @php; }
+location /thumb.php5           { try_files /var/empty @php; }
+location /thumb_handler.php    { try_files /var/empty @php; }
+location /thumb_handler.php5   { try_files /var/empty @php; }
+location /wiki.phtml           { try_files /var/empty @php; }
+
+location @rewrite {
+    rewrite ^/(.*)$ /index.php?title=$1&$args;
+}
+
+location @php {
+    # obviously, change this according to your PHP setup
+    include fastcgi.conf;
+    fastcgi_pass unix:/run/php-fpm/wiki.sock;
+}
+

We are now using this configuration on ParabolaWiki, but with an alias for location = /favicon.ico to the correct file in the skin, and with FastCGI caching for PHP.

+

The only thing I don't like about this is the try_files /var/emtpy bits--surely there is a better way to have it go to one of the @ location blocks, but I couldn't figure it out.

+ +
+ + + -- cgit v1.2.3