ログを見ると以下のようなエラーが返ってきてました。
502 Bad Gateway Error Nginx connect() to unix:/tmp/unicorn.sock failed
環境
- Ruby on Rails4.2.x
- unicorn
- nginx
解決
*.confファイルのunicorn.sockのパスの位置を確認しましょう。
upstream unicorn_server {
server unix:/var/www/#{application}/current/tmp/unicorn.sock
fail_timeout=0;
}
server {
listen 80;
server_name sever_name;
keepalive_timeout 5;
root /var/www/#{application}/current/public;
access_log /var/log/nginx/#{application}_access.log;
error_log /var/log/nginx/#{application}_error.log;
error_page 500 502 503 504 /500.html;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://unicorn_server;
}
# location ~ ^/assets/ {
# root /var/www/#{application}/current/public;
# }
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/#{application}/current/public;
}
}