Strange try_files behaviour

itpp2012 nginx-forum at nginx.us
Tue Jul 15 09:34:23 UTC 2014


With pure Lua and no IF (crossposted in openresty group):

        location / {
            try_files $uri $uri/ =404;
            index  index.html index.htm;
        }
        location ~ \.php$ {
            try_files $uri $uri/ =404;
            rewrite_by_lua '
              local s = 0; local v = 0;
              local source_fname = ngx.var.document_root ..
"/maintenance_mode.html";
              local file = io.open(source_fname);
              if file then v=1; file:close(); end;
              if string.find(ngx.var.remote_addr, "^10.10.30.") then v=0;
end;
              if v>0 then return ngx.exit(503); end;
            ';
            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;
        }

With nginx for Windows you can use 513 to keep your 503 handler intact.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,251650,251777#msg-251777



More information about the nginx mailing list