#実現したいこと
AWSを使用しデプロイした Rails アプリケーションを「http://ドメイン」でアクセスできるようにしたい。
現状、「http://IPアドレス」と「http://www.ドメイン」では問題なくアクセスできるのですが、「http://ドメイン」になると、とたんにアクセスができなくなってしまいます。
※ドメインの設定は Route53 → レコードの作成 → AレコードでIPアドレスを設定し登録
##現状の設定
使用ツール
・Rails 5.2.4.1
・amazon linux 2
・Route 53
・nginx 1.12.2
参考にした記事
https://qiita.com/Yuki_Nagaoka/items/975b7598806d6ae0c0b2
Nginxの設定ファイル
error_log /var/www/rails/アプリ名/log/nginx.error.log; access_log /var/www/rails/アプリ名/log/nginx.access.log; upstream unicorn_server { server unix:/var/www/rails/アプリ名/tmp/sockets/.unicorn.sock fail_timeout=0; } server { listen 80; client_max_body_size 4G; server_name ドメイン名; keepalive_timeout 5; # Location of our static files root /var/www/rails/アプリ名/public; location ~ ^/assets/ { root /var/www/rails/アプリ名/public; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://unicorn_server; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/rails/アプリ名/public; } }
エラーログ
production.log
I, [2020-08-04T07:06:44.993294 #5476] INFO -- : [cd89d109-4761-458b-92c2-419ec4ce839c] Started GET "/nginx-logo.png" for 153.162.204.151 at 2020-08-04 07:06:44 +0000 F, [2020-08-04T07:06:44.994218 #5476] FATAL -- : [cd89d109-4761-458b-92c2-419ec4ce839c] F, [2020-08-04T07:06:44.994257 #5476] FATAL -- : [cd89d109-4761-458b-92c2-419ec4ce839c] ActionController::RoutingError (No route matches [GET] "/nginx-logo.png"): F, [2020-08-04T07:06:44.994319 #5476] FATAL -- : [cd89d109-4761-458b-92c2-419ec4ce839c] F, [2020-08-04T07:06:44.994410 #5476] FATAL -- : [cd89d109-4761-458b-92c2-419ec4ce839c] actionpack (5.2.4.1) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] actionpack (5.2.4.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] railties (5.2.4.1) lib/rails/rack/logger.rb:38:in `call_app' [cd89d109-4761-458b-92c2-419ec4ce839c] railties (5.2.4.1) lib/rails/rack/logger.rb:26:in `block in call' [cd89d109-4761-458b-92c2-419ec4ce839c] activesupport (5.2.4.1) lib/active_support/tagged_logging.rb:71:in `block in tagged' [cd89d109-4761-458b-92c2-419ec4ce839c] activesupport (5.2.4.1) lib/active_support/tagged_logging.rb:28:in `tagged' [cd89d109-4761-458b-92c2-419ec4ce839c] activesupport (5.2.4.1) lib/active_support/tagged_logging.rb:71:in `tagged' [cd89d109-4761-458b-92c2-419ec4ce839c] railties (5.2.4.1) lib/rails/rack/logger.rb:26:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] actionpack (5.2.4.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] actionpack (5.2.4.1) lib/action_dispatch/middleware/request_id.rb:27:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] rack (2.2.2) lib/rack/method_override.rb:24:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] rack (2.2.2) lib/rack/runtime.rb:22:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] activesupport (5.2.4.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] actionpack (5.2.4.1) lib/action_dispatch/middleware/executor.rb:14:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] rack (2.2.2) lib/rack/sendfile.rb:110:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] railties (5.2.4.1) lib/rails/engine.rb:524:in `call' [cd89d109-4761-458b-92c2-419ec4ce839c] unicorn (5.4.1) lib/unicorn/http_server.rb:606:in `process_client' [cd89d109-4761-458b-92c2-419ec4ce839c] unicorn (5.4.1) lib/unicorn/http_server.rb:701:in `worker_loop' [cd89d109-4761-458b-92c2-419ec4ce839c] unicorn (5.4.1) lib/unicorn/http_server.rb:549:in `spawn_missing_workers' [cd89d109-4761-458b-92c2-419ec4ce839c] unicorn (5.4.1) lib/unicorn/http_server.rb:142:in `start' [cd89d109-4761-458b-92c2-419ec4ce839c] unicorn (5.4.1) bin/unicorn_rails:209:in `<top (required)>' [cd89d109-4761-458b-92c2-419ec4ce839c] /home/admin/.rbenv/versions/2.5.3/bin/unicorn_rails:23:in `load' [cd89d109-4761-458b-92c2-419ec4ce839c] /home/admin/.rbenv/versions/2.5.3/bin/unicorn_rails:23:in `<top (required)>' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/cli/exec.rb:63:in `load' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/cli/exec.rb:63:in `kernel_load' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/cli/exec.rb:28:in `run' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/cli.rb:476:in `exec' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/cli.rb:30:in `dispatch' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/cli.rb:24:in `start' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) exe/bundle:46:in `block in <top (required)>' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) lib/bundler/friendly_errors.rb:123:in `with_friendly_errors' [cd89d109-4761-458b-92c2-419ec4ce839c] bundler (2.1.4) exe/bundle:34:in `<top (required)>' [cd89d109-4761-458b-92c2-419ec4ce839c] /home/admin/.rbenv/versions/2.5.3/bin/bundle:23:in `load' [cd89d109-4761-458b-92c2-419ec4ce839c] /home/admin/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
エラーログで nginx-logo.png
が引っかかり調べたのですが、本件に該当するような内容は見つからず解決の糸口を見つけ出せずにいます。
ご教示頂きたくよろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/04 11:35