Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im banging my head against a table trying to figure out what is causing redirection cycle in my nginx configuration when trying to access URL which does not exist Configuration goes as follows:

server {
    root  /var/www/;

        access_log /var/log/nginx/;
    error_log  /var/log/nginx/ debug;

        location ~* \.php.$ {
        # Proxy all requests with an URI ending with .php*
        # (includes PHP, PHP3, PHP4, PHP5...)
        include /etc/nginx/fastcgi.conf;

        # all other files
        location / {
            root  /var/www/;
        try_files $uri $uri/ ;

    error_page 404 /errors/404.html;
        location /errors/ {
                alias /var/www/errors/;

        #this loads custom logging configuration which disables favicon error logging
        include /etc/nginx/drop.conf;

this domain is a simple STATIC HTML site just for some testing purposes. I'd expect that the error_page directive would kick in in response to PHP-FPM not being able to find given files as I have fastcgi_intercept_errors on; in http block and nave error_page set up, but I'm guessing the request fails even before that somewhere on internal redirects. Any help would be much appreciated.

share|improve this question
Is the client browser reporting a redirect loop, or is nginx? If it's the client, what location are the redirects to? – Shane Madden Jul 7 '12 at 5:54
both are reporting it. Client eventually ends up with the URL of /errors//errors//errors//errors//errors/...404.html – gyre Jul 7 '12 at 13:44
What's the log entry from nginx look like? – Shane Madden Jul 7 '12 at 20:39
up vote 7 down vote accepted

The culprit is: try_files $uri $uri/ ; (note that the last parameter is return code or URI to internal redirect)

If none of the files were found, an internal redirect to the uri specified by the last parameter is made.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.