nginxがrailsサーバーに接続してません
nginxが急に接続できなくなり、We're sorry, but something went wrong.が表示されました。
現在 failed (111: Connection refused) while connecting to upstream
というエラーが発生してしまい、ウェブサイトにアクセスできなくなりました。
以下が、nignx.error.log
の内容です。
error
1 while connecting to upstream, client: 10.0.1.171, server: www.sumigokochi2020.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/rails_app/tmp/sockets/puma.sock:/", host: "10.0.0.222" 22020/12/03 12:22:24 [error] 3277#0: *439 connect() to unix:/var/www/rails/rails_app/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream, client: 10.0.0.196, server: www.sumigokochi2020.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/rails_app/tmp/sockets/puma.sock:/", host: "10.0.0.222"
rails s -e production
を実行すると以下の結果が得られます。
=> Booting Puma => Rails 6.0.3.4 application starting in production => Run `rails server --help` for more startup options Puma starting in single mode... * Version 4.3.6 (ruby 2.7.2-p137), codename: Mysterious Traveller * Min threads: 5, max threads: 5 * Environment: production * Listening on unix:///var/www/rails/rails_app/tmp/sockets/puma.sock Use Ctrl-C to stop
error.log
の
connect() to unix:/var/www/rails/rails_app/tmp/sockets/puma.sock
とrails s -e production
実行結果の
* Listening on unix:///var/www/rails/rails_app/tmp/sockets/puma.sock
のListening先とconnect先が違うことがエラーの原因なのではないかと考えているのですが、どなたかわかる人がいました、教えて頂きたいです。
railsのproduction.log
が一切更新されてないので、Nginxの問題かなとは考えています。
## 本番環境
- AWS EC2 Linux
- Rails 6.0.3
- Nginx
Nginx.conffile
nginx/conf:nginx
1 2# For more information on configuration, see: 3# * Official English Documentation: http://nginx.org/en/docs/ 4# * Official Russian Documentation: http://nginx.org/ru/docs/ 5 6user nginx; 7worker_processes auto; 8error_log /var/log/nginx/error.log; 9pid /run/nginx.pid; 10 11# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. 12include /usr/share/nginx/modules/*.conf; 13 14events { 15 worker_connections 1024; 16} 17 18http { 19 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 20 '$status $body_bytes_sent "$http_referer" ' 21 '"$http_user_agent" "$http_x_forwarded_for"'; 22 23 access_log /var/log/nginx/access.log main; 24 25 sendfile on; 26 tcp_nopush on; 27 tcp_nodelay on; 28 keepalive_timeout 65; 29 types_hash_max_size 4096; 30 31 include /etc/nginx/mime.types; 32 default_type application/octet-stream; 33 34 # Load modular configuration files from the /etc/nginx/conf.d directory. 35 # See http://nginx.org/en/docs/ngx_core_module.html#include 36 # for more information. 37 include /etc/nginx/conf.d/*.conf; 38 # server{}欄を変更して,httpでアクセスされたものをhttpsにリダイレクトさせる 39 server { 40 listen 80; 41 listen [::]:80; 42 server_name www.sumigokochi2020.com; 43 root /usr/share/nginx/html; 44 45 # Load configuration files for the default server block. 46 include /etc/nginx/default.d/*.conf; 47 48 error_page 404 /404.html; 49 location = /40x.html { 50 } 51 52 error_page 500 502 503 504 /50x.html; 53 location = /50x.html { 54 } 55 } 56}
nginx/conf.d/rails_app.conf
# log directory error_log /var/www/rails/rails_app/log/nginx.error.log; #自分のアプリケーション名に変更 access_log /var/www/rails/rails_app/log/nginx.access.log; #自分のアプリケーション名に変更 # max body size client_max_body_size 2G; upstream app_server { # for UNIX domain socket setups server unix:/var/www/rails/rails_app/tmp/sockets/puma.sock fail_timeout=0; #自分のアプリケーション名に変更 } server { listen 80; server_name www.sumigokochi2020.com; #自分のElasticIP # nginx so in:creasing this is generally safe... keepalive_timeout 5; # path for static files root /var/www/rails/rails_app/public; #自分のアプリケーション名に変更 # page cache loading try_files $uri/index.html $uri.html $uri @app; location @app { # HTTP headers proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } # Rails error pages error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/rails/rails_app/public; #自分のアプリケーション名に変更 } }
回答1件
あなたの回答
tips
プレビュー