我正在尝试设置Nginx,Unicorn和Rails应用程序以一起工作.Nginx和Nnicorn正在运行,我使用ps命令进行了检查.但是当我尝试访问我的页面时,我却遇到了502 Bad GatewayNginx错误日志包含以下行:2015/03/18 19:53:26 [e...
我正在尝试设置Nginx,Unicorn和Rails应用程序以一起工作.
Nginx和Nnicorn正在运行,我使用ps命令进行了检查.
但是当我尝试访问我的页面时,我却遇到了502 Bad Gateway
Nginx错误日志包含以下行:
2015/03/18 19:53:26 [error] 14319#0: *1 connect() to
unix:/var/sockets/unicorn.mypage.sock failed (11: Resource temporarily
unavailable) while connecting to upstream
可能是什么问题?
我的/etc/nginx/conf.d/default.conf
upstream app {
server unix:/var/sockets/unicorn.mypage.sock fail_timeout=0;
}
server {
listen 80;
server_name mypage.com;
# Application root, as defined previously
root /home/rails/mypage/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.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://app;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
/home/rails/mypage/config/unicorn.rb
working_directory "/home/rails/mypage"
pid "/home/rails/mypage/pids/unicorn.pid"
stderr_path "/home/rails/mypage/log/unicorn.log"
stdout_path "/home/rails/mypage/log/unicorn.log"
listen "/var/sockets/unicorn.mypage.sock", backlog: 1024
worker_processes 2
timeout 30
解决方法:
它看起来像套接字问题,但是套接字关闭时通常是(111:连接被拒绝),所以我认为这是应用程序问题(高负载,执行缓慢等).
尝试减少积压,然后再次查看日志以获取详细信息:
listen "/var/sockets/unicorn.mypage.sock", backlog: 64
number of clients' rel='nofollow' target='_blank'>:backlog => number of clients
本文标题为:ruby-on-rails-Nginx,Unicorn和Rails = 502错误网关
- Swift超详细讲解指针 2023-07-08
- Golang http.Client设置超时 2023-09-05
- Ruby on Rails在Ping ++ 平台实现支付 2023-07-22
- Go Web开发进阶实战(gin框架) 2023-09-06
- R语言绘图数据可视化pie chart饼图 2022-12-10
- Ruby 迭代器知识汇总 2023-07-23
- 汇编语言程序设计之根据输入改变屏幕颜色的代码 2023-07-06
- R语言关于二项分布知识点总结 2022-11-30
- Ruby的字符串与数组求最大值的相关问题讨论 2023-07-22
- R语言-如何切换科学计数法和更换小数点位数 2022-11-23