Strange try_files behaviour

itpp2012 nginx-forum at
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 ..
              local file =;
              if file then v=1; file:close(); end;
              if string.find(ngx.var.remote_addr, "^10.10.30.") then v=0;
              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 
            include        fastcgi_params;

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

Posted at Nginx Forum:,251650,251777#msg-251777

More information about the nginx mailing list