# How to setup nginx to follow 302

**URL:** <https://www.ruby-forum.com/t/how-to-setup-nginx-to-follow-302/236842>\
**Category:** NGINX\
**Created:** [October 7, 2013, 10:57am UTC](https://www.ruby-forum.com/t/how-to-setup-nginx-to-follow-302/236842 "2013-10-07T10:57:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 7, 2013, 10:57am UTC](https://www.ruby-forum.com/t/how-to-setup-nginx-to-follow-302/236842/1 "2013-10-07T10:57:12Z")

</div>

Hello colleagues,  
Last week I tried to configure nginx to follow 302 through upstream  
instead  
of relay it to the client.  
My config now is like the next one:

http {  
proxy\_cache\_path /home/toli/nginx/run/cache keys\_zone=zone\_c1:256m  
inactive=5d max\_size=30g;

```
upstream up_cdn_cache_l2 {
    server 127.0.1.1:8081 weight=100;
}

server {

    listen 127.0.0.1:8080;
    resolver 8.8.8.8;

    location / {
        proxy_cache zone_c1;
        proxy_pass http://127.0.1.1:8081;
        proxy_temp_path tmp;
        error_page 301 302 307 @redir;
    }

    location @redir {
        set $foo $upstream_http_location;
        proxy_pass $foo;
        proxy_cache zone_c1;
        proxy_temp_path tmp ;
    }
}

```

}

With this config ginx is trying to connect to the server taken from  
location header. In wireshark I found new tcp connection to it but there  
is  
not http request over this connection and after some time 504: Gateway  
Time-out is received.  
So at the client site I receive “504: Gateway Time-out.”

Do you have any idea why nginx dont send http request to the second  
server?
