Ruby on rails nginx&;上的Rails重定向失败;独角兽设置
我已经设置了在nginx和unicorn上运行的设置,如Railscasts第293集所述 当我尝试重定向时,例如Ruby on rails nginx&;上的Rails重定向失败;独角兽设置,ruby-on-rails,ruby,redirect,nginx,unicorn,Ruby On Rails,Ruby,Redirect,Nginx,Unicorn,我已经设置了在nginx和unicorn上运行的设置,如Railscasts第293集所述 当我尝试重定向时,例如 class PostsController < ApplicationController def show redirect_to posts_path, :notice => "Test redirect" end end 这对我很有用: upstream unicorn { server unix:/tmp/unicorn.example.s
class PostsController < ApplicationController
def show
redirect_to posts_path, :notice => "Test redirect"
end
end
这对我很有用:
upstream unicorn {
server unix:/tmp/unicorn.example.sock fail_timeout=0;
}
server {
listen 80;
listen localhost;
server_name www.example.com;
keepalive_timeout 5;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# this is required for HTTPS:
# proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
}
在我的./config/unicorn.rb文件中:
# Listen on a Unix data socket
listen "/tmp/unicorn.example.sock", :backlog => 64
我有一个类似的设置,但不是
location@unicorn
,而是location/
。“你试过了吗?”马丁弗罗斯特:是的,没用。在我看来,它使用代理传递URL作为基本URL,而不是域名。你也可以发布你的/config/unicorn.rb
内容吗?e、 g.带有listen
指令的行。
# Listen on a Unix data socket
listen "/tmp/unicorn.example.sock", :backlog => 64