Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to setup of proxy using nginx, but it redirects rather than proxy it (at least that's what it looks like). My virtual host config:

server {
    listen 80;


    location / {
        proxy_pass    ;
        proxy_redirect          off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size    10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout   90;
        proxy_send_timeout      90;
        proxy_read_timeout      90;
        proxy_buffers           32 4k;

Did I screw up somewhere?

The output of the cURL request to my proxy:

> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/ zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host:
> Accept: */*
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Sat, 19 May 2012 00:27:35 GMT
< Content-Type: text/html
< Connection: keep-alive
< X-Powered-By: PHP/5.4.1
< Location:
< Content-Length: 0
share|improve this question
Where is the client being redirected to? – mgorven May 19 '12 at 0:08 – user6669 May 19 '12 at 0:20
Can you paste the output of curl -v to determine whether this is an HTTP redirect or something else. – mgorven May 19 '12 at 0:22
@mgorven edited my question. It does a 301. – user6669 May 19 '12 at 0:26

It's probably the proxied site which is sending a redirect (which nginx simply passes on to the client). You want to set proxy_redirect to default so that nginx modifies the redirect appropriately.

Edit: proxy_redirect default is supposed to handle this situation, but it's not for some reason. Try the following config:

proxy_redirect /;
share|improve this answer
There is not on directive for proxy_redirect – user6669 May 18 '12 at 23:20
Apologies, that should be default. – mgorven May 18 '12 at 23:41
Results in the same thing (e.g. a redirect) :( – user6669 May 18 '12 at 23:51
Edited with another suggestion. – mgorven May 19 '12 at 0:49

Your Answer


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.