【发布时间】:2018-03-05 16:14:39
【问题描述】:
我有实现 302 重定向到服务器某些内容的服务器。
例如当用户请求http://a.com/images/a.jpg时,我的服务器会向server B: http://b.com/images/a.jpg发出请求,但server B可能会返回302。所以我想要的是当server B返回302时,我的服务器会发送一个@ 987654325@给用户。
server {
listen 80;
server_name a.com;
location / {
proxy_pass http://www.girls-av.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache nginx-cache;
proxy_cache_valid 200 302 304 1440m;
proxy_intercept_errors on;
error_page 301 302 = @handler;
}
location @handler {
proxy_pass /home/git/a/images/logo.png;
}
}
// but I got an error "invalid URL prefix"
那我试试
location @handler {
proxy_pass http://a.com/images/logo.png;
}
// but I got this error ""proxy_pass" cannot have URI part in location given by regular expression, or inside named location"
我也试试
location @handler {
alias /home/git/a/images/logo.png;
}
// but I got another error the "alias" directive cannot be used inside the named location;
我该怎么办,有人可以帮忙吗?
【问题讨论】:
标签: nginx http-status-code-302