0
我有服务器实现302重定向到服务器的一些内容。如何发送一个静态文件,当nginx代理302重定向
例如,当用户请求http://a.com/images/a.jpg
,我的服务器将请求server B: http://b.com/images/a.jpg
,但server B
可返回302,所以我想是时候server B
回到302,我的服务器会发送一个a.logo
用户。
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;
什么sholud我做的,任何人都可以帮忙吗?
它没”当用户请求'a.com/a/b/c.jpg'时,它会尝试返回'/ tmp/logo/a/b/c.jpg'而不是'tmp/logo/logo.png' – chenkehxx
你是否设置了'try_files $ uri /logo.png = 404;'通知我刚刚测试并运行的'/ logo.png' – nbari
我只是尝试使用'try_files/tmp/log/logo.png',它现在可以工作。 – chenkehxx