【发布时间】:2011-12-31 03:53:53
【问题描述】:
如 Railscasts 第 293 集所述,我已设置为在 nginx 和 unicorn 上运行。
当我尝试重定向时,比如
class PostsController < ApplicationController
def show
redirect_to posts_path, :notice => "Test redirect"
end
end
我被重定向到 http://unicorn/posts 而不是 http://mydomain.com/posts
这是我的应用程序的 nginx.conf
upstream unicorn {
server unix:/tmp/unicorn.scvrush.sock fail_timeout=0;
}
server {
listen 80 default deferred;
# server_name example.com;
root /var/apps/current/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
keepalive_timeout 5;
}
【问题讨论】:
-
我有类似的设置,但不是
location @unicorn,而是location /。你试过吗? -
@MartinFrost 是的,没有帮助。在我看来,它使用 proxy_pass URL 作为基本 URL,而不是域名。
-
您也可以发布您的
./config/unicorn.rb内容吗?例如带有listen指令的行。
标签: ruby-on-rails ruby redirect nginx unicorn