Q&A
EC2上に/var/www/diary_appとしてアプリを構成しています。
EC2のNginx設定のファイルを/etc/nginx/nginx.conf
として起点となるファイルから/etc/nginx/conf.d/app.conf
と別ファイルを構成しました。
bundle exec rails s -e production
とするとPumaは立ち上がるのでうまく設定したつもりですが502エラーになり、
Nginxのログによるとpuma.sock
がないと言われますが、diary_app/tmp/sockets/puma.sock
にはソケットは存在していました。
2022/02/24 06:20:08 [crit] 3474#0: *348 connect() to unix:///diary_app/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 10.0.12.137, server: 35.77.159.241, request: "GET / HTTP/1.1", upstream: "http://unix:///diary_app/tmp/sockets/puma.sock:/", host: "10.0.11.191" 2022/02/24 06:20:08 [crit] 3474#0: *348 connect() to unix:///diary_app/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 10.0.12.137, server: 35.77.159.241, request: "GET / HTTP/1.1", upstream: "http://unix:///diary_app/tmp/sockets/puma.sock:/500.html", host: "10.0.11.191"
なのでEC2に設定しているNginx の/etc/nginx/conf.d/diary_app.conf
の設定の指定場所が誤っているのでしょうか。
色々と/var/wwwを抜いてみたりと書き換えてきましたが相変わらず502エラーが出てしまいます。
ご教授お願いいたします。
ps -aux | grep "puma"
でpumaの起動は確認できましたがpuma.sockに繋がらないみたいです
ターミナル1
[sirius@ip-10-0-11-191 diary_app]$ bundle exec rails s -e production => Booting Puma => Rails 5.2.6.2 application starting in production => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.6 (ruby 2.6.4-p104), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: production * Listening on unix:///var/www/diary_app/tmp/sockets/puma.sock Use Ctrl-C to stop
ターミナル2
[sirius@ip-10-0-11-191 diary_app]$ ps -aux | grep "puma" sirius 12144 0.8 13.3 967692 131876 pts/2 Sl+ 01:38 0:02 puma 3.12.6 (unix:///var/www/diary_app/tmp/sockets/puma.sock) [diary sirius 12295 0.0 0.0 119440 912 pts/3 S+ 01:42 0:00 grep --color=auto puma
nginx.error.log
2022/02/25 01:36:31 [crit] 11943#0: *193 connect() to unix:///diary_app/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 10.0.11.184, server: 35.77.159.241, request: "GET / HTTP/1.1", upstream: "http://unix:///diary_app/tmp/sockets/puma.sock:/500.html", host: "10.0.11.191"
(EC2) /etc/nginx/nginx.conf
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; index index.html index.htm; upstream puma { server unix:///var/www/diary_app/tmp/sockets/puma.sock; } server { listen 80 default_server; listen [::]:80 default_server; server_name www.diary_app.net; root /var/www/diary_app/public; location / { try_files $uri $uri/index.html $uri.html @webapp; } location @webapp { proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://puma; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } server { listen 443 ssl; server_name www.diary_app.net; location @webapp { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://puma; } } }
(EC2) /etc/nginx/conf.d/app.conf
# (EC2)/etc/nginx/conf.d/app.conf error_log /var/www/diary_app/log/nginx.error.log; access_log /var/www/diary_app/nginx.access.log; upstream app_server { # for UNIX domain socket setups server unix:/var/www/diary_app/tmp/sockets/puma.sock fail_timeout=0; } server { listen 80; server_name www.diary_app.net; # nginx so increasing this is generally safe... # path for static files root /var/www/diary_app/current/public; # page cache loading try_files $uri/index.html $uri @app_server; location / { # HTTP headers proxy_pass http://app_server; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; } # Rails error pages error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/diary_app/current/public; } client_max_body_size 4G; keepalive_timeout 5; }
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。