ruby-on-rails – Nginx,Rails和Oauth.上游过早关闭连接
我有一个奇怪的问题出现在生产环境中,只有当我使用nginx和独角兽.当我使用没有nginx的独角兽,它不会发生.
问题.我有一个简单的oauth身份验证,允许用户通过GitHub注册.在GitHub的授权页面上按“允许”后,用户被重定向到回呼路由.然后他/她获得302坏网关错误.
Ther是我的nginx配置. upstream unicorn { server unix:/tmp/unicorn.tm.sock fail_timeout=0; } server { listen 80 default deferred; client_max_body_size 4G; server_name _; keepalive_timeout 75s; proxy_connect_timeout 60s; proxy_read_timeout 60s; root /vagrant/public; try_files $uri/index.html $uri.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://unicorn; proxy_buffer_size 16k; proxy_busy_buffers_size 16k; } error_page 500 502 503 504 /500.html; } 所以我的问题是为什么会发生这种情况,有没有可能的修复? 我一直在搜索一段时间,但没有运气. 更新 感谢您的评论,我刚刚尝试设置fail_timeout = 30s,它有帮助,但是请求大约需要40秒才能完成.但是不管怎么说,我会尝试使用这个参数来过期. 我更新了我的配置,根据建议,但仍然,得到相同的错误. 另外,这是独角兽错误日志.似乎它杀死了需要超过30秒的请求,但我猜从oauth站点重定向不可能那么长 (github) Request phase initiated. (github) Callback phase initiated. E,[2012-12-26T19:33:13.058183 #6002] ERROR -- : worker=0 PID:6005 timeout (31s > 30s),killing E,[2012-12-26T19:33:13.067011 #6002] ERROR -- : reaped #<Process::Status: pid 6005 SIGKILL (signal 9)> worker=0 I,[2012-12-26T19:33:13.067198 #6002] INFO -- : worker=0 spawning... I,[2012-12-26T19:33:13.068631 #6012] INFO -- : worker=0 spawned pid=6012 I,[2012-12-26T19:33:13.068726 #6012] INFO -- : Refreshing Gem list I,[2012-12-26T19:33:17.140948 #6012] INFO -- : worker=0 ready 独角兽配置 rails_env = ENV['RAILS_ENV'] || 'production' worker_processes 1 listen "/tmp/unicorn.tm.sock",:backlog => 64 listen 8080,:tcp_nopush => true timeout 30 pid "/tmp/unicorn.pid" stderr_path "/tmp/unicorn.log" stdout_path "/tmp/unicorn.log" check_client_connection false 解决方法ERROR -- : worker=0 PID:6005 timeout (31s > 30s),killing 不用说,你只需要安装超时到你的unicorn配置的30多个 至少尝试一下 timeout 60 http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-timeout (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |