##前提・困っていること
ec2にデプロイしたのですが502 Bad Gateway nginx/1.18.0と表示されます。
var/www/game-bug-app/src/tmp/unicorn.sockの中身を確認しようとしましたが権限がなく開けれませんでした。
/home/ec2-user/var/www/game-bug-app/src/tmp
[ec2-user@ip-10-0-0-34 tmp]$ ls -la 合計 12 drwxrwxr-x 7 ec2-user ec2-user 170 3月 23 03:42 . drwxrwxr-x 11 ec2-user ec2-user 4096 3月 21 23:43 .. drwxrwxr-x 5 ec2-user ec2-user 53 3月 21 21:18 cache -rw-rw-r-- 1 ec2-user ec2-user 128 3月 21 20:42 development_secret.txt drwxrwxr-x 2 ec2-user ec2-user 6 3月 22 21:50 miniprofiler drwxrwxr-x 2 ec2-user ec2-user 6 3月 22 01:12 pids -rw-rw-r-- 1 ec2-user ec2-user 0 3月 21 20:44 restart.txt drwxrwxr-x 2 ec2-user ec2-user 6 3月 21 23:52 sessions drwxrwxr-x 2 ec2-user ec2-user 6 3月 21 20:44 sockets -rw-r--r-- 1 ec2-user ec2-user 6 3月 21 23:52 unicorn.pid srwxrw-r-- 1 ec2-user ec2-user 0 3月 21 23:52 unicorn.sock
上記のように権限を与えているのですが。。。
Nginxのログを確認しましたら、下記のエラーログが発生していました。
##エラー
$sudo tail /var/log/nginx/error.log 2021/03/23 02:21:26 [crit] 3695#0: *13 connect() to unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 02:21:26 [crit] 3695#0: *13 connect() to unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 02:21:26 [crit] 3695#0: *13 connect() to unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/favicon.ico", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 02:21:26 [crit] 3695#0: *13 connect() to unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 02:21:52 [crit] 3746#0: *1 connect() to unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 02:21:52 [crit] 3746#0: *1 connect() to unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 02:21:53 [crit] 3746#0: *1 connect() to unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/favicon.ico", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 02:21:53 [crit] 3746#0: *1 connect() to unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 02:22:25 [crit] 3746#0: *7 connect() to unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.0", upstream: "http://unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/" 2021/03/23 02:22:25 [crit] 3746#0: *7 connect() to unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock failed (13: Permission denied) while connecting to upstream, client: ☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.0", upstream: "http://unix:home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock:/500.html"
/etc/nginx/conf.d/local.conf
upstream unicorn { server unix:/home/ec2-user/var/www/game-bug-app/src/tmp/unicorn.sock; } server { listen 80; server_name ☓.☓☓☓.☓☓.☓☓☓; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root var/www/game-bug-app; client_max_body_size 100m; error_page 404 /404.html; 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; } }
回答1件
あなたの回答
tips
プレビュー