Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 {
        listen       127.0.0.1:8080;
        server_name  .somedomain.com;
    root  /var/www/somedomain.com;

        access_log /var/log/nginx/somedomain.com-access.nginx.log;
    error_log  /var/log/nginx/somedomain.com-error.nginx.log 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/somedomain.com;
        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

1 Answer 1

up vote 4 down vote accepted

The culprit is: try_files $uri $uri/ ;

http://nginx.org/r/try_files (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

 
discard

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.