nginx反向代理302自定义处理程序不起作用

时间:2019-03-11 02:57:37

标签: nginx nginx-reverse-proxy

location / {
    fastcgi_intercept_errors on;
    proxy_pass https://drive.google.com/uc?$query_string;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host drive.google.com;
    proxy_set_header Referer https://drive.google.com;
    error_page 301 302 307 = @handle_redirects;

}
location @handle_redirects {
    set $redirect_location '$upstream_http_location';
    proxy_pass $redirect_location;
    proxy_cache ngx-cache;
    proxy_cache_key $query_string;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

curl -I -A“ ua” https://server/dl?id=trhtyjkfktkghjsutrtujyuk直接返回302而不是转到handle_redirects部分,此配置可用于服务器Tengine的另一台vps,但不适用于原始版本的另一台vps nginx,不知道哪里出了问题。任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)