##前提・困っていること
ec2にデプロイしたのですが502 Bad Gateway nginx/1.18.0と表示されます。
Nginxのログを確認しましたら、下記のエラーログが発生していました。
エラーログを見ると、var/www/game-bug-app/src/tmp/unicorn.sockのようなディレクトリはありませんとなっていると思うのですが、
確認しましたところちゃんとあり困っています。
var/www/game-bug-app/src/tmp/unicorn.sockの中身を確認しようとしましたが権限がなく開けれませんでした。
ちなみに階層は、こんな感じです。
/home/ec2-user/var/www/game-bug-app/src/tmp
ご教授いただけましたら幸いです。
##エラーログ
/var/log/nginx/error.log
$sudo tail /var/log/nginx/error.log 2021/03/23 01:30:00 [crit] 3195#0: *30 connect() to unix:/var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/game-bug-app/src/tmp/unicorn.sock:/", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 01:30:00 [crit] 3195#0: *30 connect() to unix:/var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 01:30:11 [crit] 3449#0: *1 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 01:30:11 [crit] 3449#0: *1 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 01:30:11 [crit] 3449#0: *1 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/favicon.ico", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 01:30:11 [crit] 3449#0: *1 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 01:33:02 [crit] 3449#0: *8 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 01:33:02 [crit] 3449#0: *8 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET / HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓" 2021/03/23 01:33:02 [crit] 3449#0: *8 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/favicon.ico", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/" 2021/03/23 01:33:02 [crit] 3449#0: *8 connect() to unix:var/www/game-bug-app/src/tmp/unicorn.sock failed (2: No such file or directory) while connecting to upstream, client: ☓☓☓.☓☓☓.☓☓.☓☓☓, server: ☓.☓☓☓.☓☓.☓☓☓, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:var/www/game-bug-app/src/tmp/unicorn.sock:/500.html", host: "☓.☓☓☓.☓☓.☓☓☓", referrer: "http://☓.☓☓☓.☓☓.☓☓☓/"
/etc/nginx/conf.d/local.conf
upstream unicorn { server unix: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; } }
##Docker
dockerはローカル環境で使用していました、本番環境では使用してないですが一応載っけておきます。
docker-compose.yml
version: "3" services: db: image: mysql:8.0 cap_add: - SYS_NICE command: --default-authentication-plugin=mysql_native_password volumes: - ./src/db/mysql_data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: password web: build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' volumes: - ./src:/app ports: - "3000:3000" environment: RAILS_ENV: development depends_on: - db
Dockerfile
FROM ruby:2.7 ENV RAILS_ENV=production RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ && apt-get update -qq \ && apt-get install -y nodejs yarn WORKDIR /app COPY ./src /app RUN bundle config --local set path 'vendor/bundle' \ && bundle install
/var/log/nginx/error.log
##追記
$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"
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/03/23 02:45
2021/03/23 02:52 編集
2021/03/23 05:18
2021/03/24 10:22