Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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;

    server_name proxy.example.com;

    location / {
        proxy_pass              http://thepiratebay.se/;
        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/3.13.1.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2
> Host: proxy.pieterhordijk.com
> 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: http://thepiratebay.se/
< Content-Length: 0
<
share|improve this question
    
Where is the client being redirected to? –  mgorven May 19 '12 at 0:08
    
http://thepiratebay.se/ –  user6669 May 19 '12 at 0:20
    
Can you paste the output of curl -v http://proxy.example.com 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

1 Answer 1

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 http://thepiratebay.se/ /;
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

 
discard

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.