Short circuit logic in nginx conf (would like to override location)
I have mediawiki installed. Everything is correct in the world, except when I try to create an external directory alias (webalizer web stats). I can see that Nginx is pushing the request to /usage/*
PHP / Mediawiki. I do not want it. I literally want everything under / using / pointing to my alias and nothing else. Completely decoupled from Mediawiki code and functionality.
# in no way related to Mediawiki. I just want to serve this as static HTML.
location /usage {
alias /var/www/webalizer/wiki.longnow.org/;
}
# This answers to anything, which may be my problem
location / {
try_files $uri $uri/ @rewrite;
index index.php;
}
# A special rewrite to play nicely with Mediawiki
location @rewrite {
rewrite ^/(.*)$ /index.php?title=$1&$args;
}
# PHP, nom nom nom
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass unix:/tmp/php-fastcgi.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
I was hoping that putting the location / use directive in front of the rest would short-circuit the system, but I was messed with Django;)
source to share
To stop Nginx from further processing directives location
, it must be prefixed ^~
.
I think you still want to try_files
revert to a 404 response internally location
.
location ^~ /usage {
alias /var/www/webalizer/wiki.longnow.org/;
try_files $uri $uri/ =404;
}
See http://wiki.nginx.org/HttpCoreModule#location for reference.
source to share