7
我已經建立起來在nginx和獨角獸上運行,如Railscasts第293集中所述。Rails重定向在nginx和獨角獸設置上失敗
當我嘗試重定向,如
class PostsController < ApplicationController
def show
redirect_to posts_path, :notice => "Test redirect"
end
end
我重定向到http://unicorn/posts
代替http://mydomain.com/posts
這裏是我的應用程序
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;
}
我有一個類似的設置,但不是'位置@ unicorn'我'位置/'。你嘗試過嗎? – Frost
@MartinFrost是的,沒有幫助。在我看來,它使用proxy_pass URL作爲基本URL,而不是域名。 –
你也可以發佈你的'./config/unicorn.rb'內容嗎?例如「listen」指令的行。 – Tilo