# Getting on internal redirection cycle

**URL:** <https://www.ruby-forum.com/t/getting-on-internal-redirection-cycle/210011>\
**Category:** NGINX\
**Created:** [July 28, 2011, 11:52am UTC](https://www.ruby-forum.com/t/getting-on-internal-redirection-cycle/210011 "2011-07-28T11:52:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 28, 2011, 11:52am UTC](https://www.ruby-forum.com/t/getting-on-internal-redirection-cycle/210011/1 "2011-07-28T11:52:58Z")

</div>

Hi

I’m running into a problem where requests for 403, get caught in a  
redirect loop and eventually fail with a 500 response.  
I want to return custom 403 page for requests from germany.

###Config###

pid /var/run/nginx/nginx.pid;  
user nginx nginx;  
worker\_processes 4;  
worker\_rlimit\_nofile 30000;

events {  
worker\_connections 4028;  
use epoll;  
}

http {

geoip\_country /usr/share/GeoIP/GeoIP.dat;

geo $Default {  
default 0;  
#skip this ip from getting 403  
12.32.32.32 1;  
}

## Size Limits

client\_body\_buffer\_size 128K;  
client\_header\_buffer\_size 1M;  
client\_max\_body\_size 1M;  
large\_client\_header\_buffers 8 8k;

## Timeouts

client\_body\_timeout 60;  
client\_header\_timeout 60;  
expires 12h;  
keepalive\_timeout 60 60;  
send\_timeout 30;

## General Options

ignore\_invalid\_headers on;  
keepalive\_requests 50;  
recursive\_error\_pages on;  
sendfile on;  
server\_name\_in\_redirect off;  
server\_tokens off;

upstream [www.abcd.com](http://www.abcd.com) {  
server [www.abcd.com:443](http://www.abcd.com:443) ;  
}  
server {  
listen 12.23.34.45:80;  
server\_name [www.abcd.com](http://www.abcd.com);  
access\_log /var/log/nginx/www.abcd.com/access.log main;  
error\_log /var/log/nginx/www.abcd.com/error.log;

```
                if ($geoip_country_code = 'DE' ) {
                   set $value "${Default}I";
                 }

                if ($value = 0I){
                    return 403;
                 }

            error_page 403 /e403.html;
    location /e403.html {
      root /var/www/html/maintenance;
      internal;
    }

             ## PROXY - Web
             location / {
                    rewrite ^(.*) https://www.abcd.com$1

```

permanent;  
}

```
            # redirect server error pages to the static page

```

/50x.html  
error\_page 500 502 503 504 /50x.html;  
location = /50x.html {  
root html;  
}  
}

#### End Config

#### Error log

2011/07/28 09:25:10 [error] 20282#0: \*242010 rewrite or internal  
redirection cycle while internal redirect to “/e403.html”, client:  
122.248.163.3, server: [www.abcd.com](http://www.abcd.com), request: “GET /favicon.ico  
HTTP/1.1”, host: “[www.abcd.com](http://www.abcd.com)”

#### End Log

Location of e403.html /var/www/html/maintenance

Can someone please help me figure out the issue here.

Posted at Nginx Forum:

> **[Getting on internal redirection cycle](https://forum.nginx.org/read.php?2,213036,213036#msg-213036)**
>
> Hi I'm running into a problem where requests for 403, get caught in a redirect loop and eventually fail with a 500 response. I want to return custom 403 page for requests from germany. ###Config### pid /var/run/nginx/nginx.p
