![Nginx unicorn:firefox 重定向到 proxy_pass](https://linux22.com/image/574171/Nginx%20unicorn%EF%BC%9Afirefox%20%E9%87%8D%E5%AE%9A%E5%90%91%E5%88%B0%20proxy_pass.png)
我有以下设置来通过 unicorn 使用 rails 处理某些域:
http {
# ...
upstream unicorn_server {
# This is the socket we configured in app's config unicorn.rb
server unix:/var/www/foo.bar.com/tmp/sockets/unicorn.sock fail_timeout=0;
}
# ...
}
server {
listen foo.bar.com:80;
server_name foo.bar.com;
# ...
location / {
if (!-f $request_filename) {
proxy_pass http://unicorn_server;
break;
}
}
}
虽然 Chrome 可以正确处理它(显示 rails 应用程序),但 Firefox 和其他浏览器可能重定向到http://unicorn_server
(独角兽上游未被调用)。你能告诉我这里我遗漏了什么吗?
nginx: nginx version: nginx/1.0.10
,
unicorn v4.2.0
答案1
似乎
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;
默认情况下不包括。这样就完成了工作。