我試圖設置Nginx,Unicorn和Rails應用程序一起工作。 Nginx和Nnicorn正在運行,我使用ps命令檢查了它。Nginx,Unicorn和Rails = 502 Bad Gateway
但在嘗試訪問時,我的網頁Ive得到了502錯誤網關
Nginx的錯誤日誌中有一行:
2015年3月18日19時53分26秒[錯誤] 14319#0:* 1 connect()以 UNIX:/var/sockets/unicorn.mypage.sock失敗(11:資源暫時 不可用),同時連接到上游
可以採取什麼問題?
我/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
嘗試在套接字行下添加另一個'listen 3000',並直接連接到'http:// localhost:3000'來查看Unicorn/Rails是否工作正常 – number5 2015-03-19 05:13:31