Strange try_files behaviour
itpp2012
nginx-forum at nginx.us
Mon Jul 14 16:44:17 UTC 2014
Maxim Dounin Wrote:
-------------------------------------------------------
> And we even have a trac ticket for this:
>
> http://trac.nginx.org/nginx/ticket/86
A tested workaround with Lua and a single IF with a return then:
location ~ \.php$ {
try_files $uri $uri/ =404;
set $mmode 0;
set_by_lua $notused '
s = 0;
local source_fname = ngx.var.document_root ..
"/maintenance_mode.html";
local file = io.open(source_fname);
if file then ngx.var.mmode=1; file:close(); end;
s = string.find(ngx.var.remote_addr, "^10.10.20.");
if s then ngx.var.mmode=0; end;
';
if ($mmode) { return 503; }
index index.html index.htm index.php;
fastcgi_ignore_client_abort on;
fastcgi_pass myLoadBalancer;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251650,251756#msg-251756
More information about the nginx
mailing list