1

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
<
user6669
  • 145
  • 1
  • 1
  • 6

1 Answers1

0

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/ /;
mgorven
  • 30,615
  • 7
  • 79
  • 122