Error Messages Showing in Production - Ruby on Rails 3.1, Nginx, Unicorn

岁酱吖の 提交于 2019-12-06 14:55:31

The https listener's location @unicorn block is missing the X-Forwarded-For directive.

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

It's in your http listener, but not the https listener.

Assuming that Rails' force_ssl is successfully redirecting all of the http requests and your only errors are happening on https requests, it seems that would explain it.

Also, to be very clear, there is a well known problem in Rack/Rails3 with respect to routing errors, which you specifically mention.

https://rails.lighthouseapp.com/projects/8994/tickets/4444-can-no-longer-rescue_from-actioncontrollerroutingerror

If you're using haproxy along with nginx and unicorn (e.g. you're on Engineyard), this fix won't be enough. You'll need to override Rails with something like this:

class ActionDispatch::Request
  def local?
    Rails.env != 'production'
  end
end

Good luck!

not sure if this is applicable but we also have a link in our nginx config after the error_page line which handles the location of the /500.html pages

location = /500.html { root /path/to/rails/app/public; }

obviously substitute the path to rails app portion with your path.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!