# Error: Rewrite or internal redirection cycle after some time

**URL:** <https://www.ruby-forum.com/t/error-rewrite-or-internal-redirection-cycle-after-some-time/222918>\
**Category:** NGINX\
**Created:** [September 14, 2012, 8:47pm UTC](https://www.ruby-forum.com/t/error-rewrite-or-internal-redirection-cycle-after-some-time/222918 "2012-09-14T20:47:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 14, 2012, 8:47pm UTC](https://www.ruby-forum.com/t/error-rewrite-or-internal-redirection-cycle-after-some-time/222918/1 "2012-09-14T20:47:23Z")

</div>

My nginx configuration works fine, but suddenly after some time (mostly  
days) he begins to answer 3x and the error occurs in the log below for  
all  
requests:

2012/09/13 17:15:35 [error] 26027#0: \*4923 rewrite or internal  
redirection  
cycle while processing “/index.php”, client: 201.26.2.XXX, server:  
www.XXX.com.br, request: “GET /checkout/cart/ HTTP/1.1”, upstream:  
“fastcgi://unix:/var/run/php5-fpm-xxx.sock:”, host: “www.XXX.com.br”,  
referrer: “[BOOKROSA](http://www.XXX.com.br/product-xxx.html)”

The error only after I reload nginx configuration with  
“/etc/init.d/nginx  
reload”

What can it be?

My host config:

server {  
listen xxx.com.br:80 default;

server\_name www.xxx.com.br \*.xxx.com.br;  
root /home/xxx/www/;

location ~ ^/(admin|index.php/admin) {  
rewrite / https://$host$request\_uri permanent;  
break;  
}

rewrite ^/minify/([0-9]+)(/._.(js|css))$ /lib/minify/m.php?f=$2&d=$1  
last;  
rewrite ^/skin/m/([0-9]+)(/._.(js|css))$ /lib/minify/m.php?f=$2&d=$1  
last;

location / {  
index index.php index.html;  
try\_files $uri $uri/ @handler;  
expires 30d;  
}

location ^~ /app/ { deny all; }  
location ^~ /includes/ { deny all; }  
location ^~ /lib/ { deny all; }  
location /lib/minify/ { allow all;}  
location ^~ /media/downloadable/ { deny all; }  
location ^~ /pkginfo/ { deny all; }  
location ^~ /report/config.xml { deny all; }  
location ^~ /var/ { deny all; }

location ~/(cron.sh|cron.php|mage)$ { deny all; }  
location ^~ /app { deny all; }  
location ^~ /includes { deny all; }  
location ^~ /lib { deny all; }

location ^~ /downloader { deny all; }  
location ^~ /errors/._.(xml|phtml)$ { deny all; }  
location ^~ /media/customer { deny all; }  
location ^~ /media/downloadable { deny all; }  
location ^~ /pkginfo { deny all; }  
location ^~ /shell { deny all; }  
location ^~ /report/._.(xml|phtml)$ { deny all; }  
location ^~ /var { deny all; }

location /. { ## Disable .htaccess and other hidden files  
return 404;  
}

location @handler { ## Magento uses a common front handler  
rewrite / /index.php;  
}

location ~ .php/ { ## Forward paths like /js/index.php/x.js to  
relevant  
handler  
rewrite ^(.\*.php)/ $1 last;  
}

location ~ .php$ { ## Execute PHP scripts  
if (!-e $request\_filename) { rewrite / /index.php last; } ## Catch  
404s  
that try\_files miss

```
include /etc/nginx/naxsi.rules;

expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php5-fpm-xxx.sock;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
fastcgi_param HTTPS $http_https;
#fastcgi_param HTTPS off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_TYPE store;
fastcgi_param MAGE_RUN_CODE $magesite_xxx;
break;

```

}  
}

Posted at Nginx Forum:

> **[Error: Rewrite or internal redirection cycle after some time](https://forum.nginx.org/read.php?2,230733,230733#msg-230733)**
>
> My nginx configuration works fine, but suddenly after some time (mostly days) he begins to answer 3x and the error occurs in the log below for all requests: 2012/09/13 17:15:35 \[error\] 26027#0: \*4923 rewrite or internal redirection cycle while...

---

<div class="post-metadata">

**Author:** ![thiagotognoli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b77776/32.png) [@thiagotognoli](https://www.ruby-forum.com/u/thiagotognoli)\
**Post date:** [September 17, 2012, 9:21pm UTC](https://www.ruby-forum.com/t/error-rewrite-or-internal-redirection-cycle-after-some-time/222918/2 "2012-09-17T21:21:05Z")

</div>

Hello!

On Fri, Sep 14, 2012 at 02:47:09PM -0400, thiagotognoli wrote:

> The error only after I reload nginx configuration with “/etc/init.d/nginx  
> reload”
> 
> What can it be?

My best guest is that somebody removes /index.php (to replace it  
with a new one?) + open\_file\_cache (configured at global level?) +  
the fact that there is infinite loop in your config if there is no  
/index.php.

[…]

Maxim D.

---

<div class="post-metadata">

**Author:** ![thiagotognoli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b77776/32.png) [@thiagotognoli](https://www.ruby-forum.com/u/thiagotognoli)\
**Post date:** [September 20, 2012, 1:56am UTC](https://www.ruby-forum.com/t/error-rewrite-or-internal-redirection-cycle-after-some-time/222918/3 "2012-09-20T01:56:09Z")

</div>

Thanks for the reply, but do not know if this is the problem because the  
open\_file\_cache is not configured at global level, and index.php is not  
changed or replaced, this file was never changed because it is the  
default  
magento, have any other ideas of what might be?

I appreciate the help …

Posted at Nginx Forum:

> **[Re: Error: Rewrite or internal redirection cycle after some time](https://forum.nginx.org/read.php?2,230733,230889#msg-230889)**
>
> My nginx configuration works fine, but suddenly after some time (mostly days) he begins to answer 3x and the error occurs in the log below for all requests: 2012/09/13 17:15:35 \[error\] 26027#0: \*4923 rewrite or internal redirection cycle while...

---

<div class="post-metadata">

**Author:** ![thiagotognoli](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b77776/32.png) [@thiagotognoli](https://www.ruby-forum.com/u/thiagotognoli)\
**Post date:** [September 20, 2012, 9:48am UTC](https://www.ruby-forum.com/t/error-rewrite-or-internal-redirection-cycle-after-some-time/222918/4 "2012-09-20T09:48:53Z")

</div>

Hello!

On Wed, Sep 19, 2012 at 07:55:38PM -0400, thiagotognoli wrote:

> Thanks for the reply, but do not know if this is the problem because the  
> open\_file\_cache is not configured at global level, and index.php is not  
> changed or replaced, this file was never changed because it is the default  
> magento, have any other ideas of what might be?

May be a result of X-Accel-Redirect loop if your backend use it, or  
backend error + fastcgi\_intercept\_errors + error\_page loop (again  
if configured).

If in doubt, you may activate debug log (see  
[A debugging log](http://nginx.org/en/docs/debugging_log.html)). From debug log it  
would be clear what exactly goes on.

Maxim D.
