ruby-on-rails – 在nginx和unicorn设置上Rails重定向失败

weixin_38078903 2019-09-12 02:13:28
我按照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; }
...全文
8 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38103346 2019-09-12
  • 打赏
  • 举报
回复
这对我有用: 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

433

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧