What does this nginx error "rewrite or internal redirection cycle" mean?

Solution 1:

It's a strange one all right, though I'm going to bet the problem is with:

        try_files $uri $uri/ /index.html;

The problem here is that the second parameter here, $uri/, causes each of the files in your index directive to be tried in turn. If none are found, it then moves on to /index.html, which causes the same location block to be re-entered, and since it still doesn't exist, you get an endless loop.

I would rewrite this as:

        try_files $uri $uri/ =404;

to return a 404 error if none of the index files you specified in the index directive exist.


BTW, those requests you are seeing are Internet background noise. In particular, they are probes to determine whether your web server is an open proxy and can be abused to hide a malicious user's origin when he goes to perform malicious activity. Your server isn't an open proxy in this configuration, so you don't really need to worry about it.

Solution 2:

You will also get this error message if your index.php is entirely missing.


Solution 3:

This was annoying. It was working a few weeks ago, and it failed on me when I tried today.

I believed an upgrade of Ubuntu nginx package cause the default directory of where Ubuntu kept the standard index files changed, so the line:

root /usr/share/nginx/www;

Won't work anymore as the location of the files are at /usr/share/nginx/html.

To fix, one can just change the root pointer to the correct directory, or create a symlink to the new directory:

cd /usr/share/nginx
sudo ln -s html www

Works for me.


Solution 4:

I ran into this problem yesterday because I was testing nginx over a proxy server that had cached a redirect that no longer existed. The solution for me was to $ sudo service squid3 restart on the squid3 proxy server I was connecting through.


Solution 5:

Had this error today, spend a few hours figuring the cause. Turned out someone deleted all the site's files.

Tags:

Nginx