我正在尝试使用 nginx 设置代理,但它会重定向而不是代理(至少看起来是这样)。我的虚拟主机配置:
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;
}
}
我是不是哪里搞砸了?
输出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
<
答案1
可能是代理网站发送了重定向(nginx 只是将其传递给客户端)。您需要设置proxy_redirect
以便default
nginx 适当地修改重定向。
编辑:proxy_redirect default
应该可以处理这种情况,但不知为何却无法处理。请尝试以下配置:
proxy_redirect http://thepiratebay.se/ /;