Ruby on Railsでアプリケーションを開発後、デプロイしました。
この時点では特に問題はなかったのですが、ドメインを取得したいと考え、AWSのRoute53を使用
https://qiita.com/ymzk-jp/items/ae115ed6d0fd2d383cecの記事を参考にRoute 53は設定しました。
またnginx側での設定も必要であることがわかったため、下記ファイルのsever_nameの部分を取得したドメイン名に変更。しかし、それでもデフォルトページが表示され、変更前の状態に戻してもデフォルトページしか表示されなくなってしまいました。
どうすれば良いか教えていただきたいです。
使用しているのはAWS EC2、Unicorn、MySQLです
unicornを確認したところ、現在は起動ができず、これが原因だと思われます。
/etc/nginx/conf.d/rails.conf
upstream app_server { server unix:/var/www/アプリケーション名/shared/tmp/sockets/unicorn.sock; } server { listen 80; server_name Elastic IP 取得したドメイン名; root /var/www/アプリケーション名/current/public; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; root /var/www/アプリケーション名/current/public; } try_files $uri/index.html $uri @unicorn; location @unicorn { 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; } error_page 500 502 503 504 /500.html; }
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. 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; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; index index.html index.htm; server { listen 80 default_server; listen [::]:80 default_server; server_name localhost; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } # redirect server error pages to the static page /40x.html # error_page 404 /404.html; location = /40x.html { } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { }
nginx errorlog
2020/01/08 07:23:34 [error] 13634#0: *5434 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 124.18.104.11, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "lifehacksharing.com", referrer: "http://lifehacksharing.com/" 2020/01/08 11:10:56 [error] 3154#0: *7 connect() to unix:/var/www/lifehacksharing/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 139.162.106.181, server: 3.114.134.212, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/lifehacksharing/shared/tmp/sockets/unicorn.sock:/", host: "3.114.134.212" 2020/01/08 11:12:19 [error] 3154#0: *9 connect() to unix:/var/www/lifehacksharing/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 206.81.24.102, server: 3.114.134.212, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/lifehacksharing/shared/tmp/sockets/unicorn.sock:/", host: "3.114.134.212" 2020/01/08 11:31:34 [error] 3154#0: *16 connect() to unix:/var/www/lifehacksharing/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 34.90.133.193, server: 3.114.134.212, request: "OPTIONS / HTTP/1.0", upstream: "http://unix:/var/www/lifehacksharing/shared/tmp/sockets/unicorn.sock:/", host: "3.114.134.212" 2020/01/08 13:23:05 [error] 3288#0: *13 open() "/usr/share/nginx/html/latest/dynamic/instance-identity/document" failed (2: No such file or directory), client: 44.224.22.196, server: localhost, request: "GET http://169.254.169.254/latest/dynamic/instance-identity/document HTTP/1.1", host: "169.254.169.254" 2020/01/08 13:23:05 [error] 3288#0: *14 open() "/usr/share/nginx/html/latest/dynamic/instance-identity/document" failed (2: No such file or directory), client: 44.224.22.196, server: localhost, request: "GET http://[::ffff:a9fe:a9fe]/latest/dynamic/instance-identity/document HTTP/1.1", host: "[::ffff:a9fe:a9fe]" 2020/01/08 13:23:06 [error] 3288#0: *18 open() "/usr/share/nginx/html/latest/dynamic/instance-identity/document" failed (2: No such file or directory), client: 44.224.22.196, server: localhost, request: "GET /latest/dynamic/instance-identity/document HTTP/1.1", host: "169.254.169.254" 2020/01/08 13:23:06 [error] 3288#0: *19 open() "/usr/share/nginx/html/latest/dynamic/instance-identity/document" failed (2: No such file or directory), client: 44.224.22.196, server: localhost, request: "GET /latest/dynamic/instance-identity/document HTTP/1.1", host: "[::ffff:a9fe:a9fe]"
ターミナルでbundle exec unicorn_rails -c config/unicorn.rb -E production -Dを実行すると
bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails) ArgumentError: config_file=config/unicorn.rb would not be accessible in working_directory=/var/www/current /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:592:in `working_directory' config/unicorn.rb:8:in `reload' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `instance_eval' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:84:in `reload' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/configurator.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:77:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' master failed to start, check stderr log for details
と出て起動ができない状態になっています。
回答1件
あなたの回答
tips
プレビュー