Nginx Location Block

Julian De Marchi juliand at aspedia.net
Mon May 25 05:44:26 UTC 2015


heya-

I'm having some interesting dramas with Nginx location block. I put it
down to a misconfiguration in my conf files, but I can't locate what it
possible could be.

Briefly, my setup is using an Nginx frontend server to do SSL offloading
then pass requests to my backend Nginx servers which then process the
request via fastCGI.

My issue is when I try to access URIs like /cms/index.php?blah, the
frontend Nginx gives 404. Access with /cms/ and Nginx passes the request
to the backend.

Here is my frontend location block:

  location / {
    limit_req zone=root burst=300;
    proxy_set_header Host            $host;
    proxy_set_header X-Real-IP       $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header HTTPS             on;
    proxy_set_header X-Forwarded-HTTPS on;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_pass  http://webpool;
  }

Here is my log entry for accessing the URI.

"25/May/2015:14:33:01 +1000" "example.com" -275 428 "GET /cms/index.php
HTTP/1.1" "404" "-" "10.107.0.8" "Mozilla/5.0 (X11; Linux x86_64;
rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.6.0"

What I don't understand is this, why does Ngnix pass the URI /cms/ to my
backend fine, but add /cms/index.php to the end and it does not pass to
the backend?

I've read and re-read the below and I'm drawing blanks, as my
understanding is, it should work.
-
https://www.digitalocean.com/community/tutorials/understanding-nginx-server-and-location-block-selection-algorithms

- http://nginx.org/en/docs/http/ngx_http_core_module.html#location

Many thanks in advance for helping me understand my problem.

--julian



More information about the nginx mailing list