質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

8416閲覧

nginxからデプロイできない。curl: (7) Failed to connect to <IPアドレス> port 443: 接続を拒否されました

pandama09396862

総合スコア6

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2020/08/23 16:17

前提

AWS(Amazon Linux)
nginx/1.16.1
unicorn
RDS(postgresql)
railsのアプリ作成中。nginx,unicorn起動しデプロイしようと試みたがIPアドレスを入力しても「このサイトにアクセスできません。
<IPアドレス>で接続が拒否されました。」とエラーになってしまいます。nginx.error.logに何も表示されず原因が解明できません。3日程格闘していたがエラーを直せず。どんな些細なことでも構いませんのでご指摘いただければ幸いです。

設定値

nginx

1error_log /var/www/rails/vb_app/log/nginx.error.log; 2access_log /var/www/rails/vb_app/log/nginx.access.log; 3 4client_max_body_size 2G; 5upstream app_server { 6 server unix:/var/www/rails/vb_app/tmp/sockets/.unicorn.sock fail_timeout=0; 7} 8server_names_hash_bucket_size 128; 9server { 10 listen 80; 11 server_name 54.95.244.26; 12 keepalive_timeout 5; 13 root /var/www/rails/vb_app/public; 14 try_files $uri/index.html $uri.html $uri @app; 15 location @app { 16 # HTTP headers 17 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 18 proxy_set_header Host $http_host; 19 proxy_redirect off; 20 proxy_pass http://app_server; 21 } 22 # Rails error pages 23 error_page 500 502 503 504 /500.html; 24 location = /500.html { 25 root /var/www/rails/vb_app/public; 26 deny all; 27 } 28}

unicorn

1# set lets 2 $worker = 2 3 $timeout = 30 4 $app_dir = "/var/www/rails/vb_app" 5 $listen = File.expand_path 'tmp/sockets/.unicorn.sock', $app_dir 6 $pid = File.expand_path 'tmp/pids/unicorn.pid', $app_dir 7 $std_log = File.expand_path 'log/unicorn.log', $app_dir 8 # set config 9 worker_processes $worker 10 working_directory $app_dir 11 stderr_path $std_log 12 stdout_path $std_log 13 timeout $timeout 14 listen $listen 15 pid $pid 16 # loading booster 17 preload_app true 18 # before starting processes 19 before_fork do |server, worker| 20 defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! 21 old_pid = "#{server.config[:pid]}.oldbin" 22 if old_pid != server.pid 23 begin 24 Process.kill "QUIT", File.read(old_pid).to_i 25 rescue Errno::ENOENT, Errno::ESRCH 26 end 27 end 28 end 29 # after finishing processes 30 after_fork do |server, worker| 31 defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection 32 end 33
ps -ef | grep unicorn | grep -v grep shimo 4579 1 0 15:39 ? 00:00:01 unicorn_rails master -c /var/www/rails/vb_app/config/unicorn.conf.rb -D -E production shimo 4581 4579 0 15:39 ? 00:00:00 unicorn_rails worker[0] -c /var/www/rails/vb_app/config/unicorn.conf.rb -D -E production shimo 4582 4579 0 15:39 ? 00:00:00 unicorn_rails worker[1] -c /var/www/rails/vb_app/config/unicorn.conf.rb -D -E production
ps -ef | grep nginx | grep -v grep root 4679 1 0 15:42 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf shimo 4681 4679 0 15:42 ? 00:00:00 nginx: worker process
$ sudo netstat -anltp | grep LISTEN [sudo] password for shimo: tcp 0 0 0.0.0.0:38143 0.0.0.0:* LISTEN 2371/rpc.statd tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2350/rpcbind tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4679/nginx tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2621/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2653/sendmail tcp 0 0 :::36843 :::* LISTEN 2371/rpc.statd tcp 0 0 :::111 :::* LISTEN 2350/rpcbind tcp 0 0 :::80 :::* LISTEN 4679/nginx tcp 0 0 :::22 :::* LISTEN 2621/sshd
$ curl -i 54.95.244.26 HTTP/1.1 301 Moved Permanently Server: nginx/1.16.1 Date: Sun, 23 Aug 2020 16:06:12 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive Location: https://54.95.244.26/ $ curl -i https://54.95.244.26/ curl: (7) Failed to connect to 54.95.244.26 port 443: 接続を拒否されました

試したこと

ファイヤーウォールは稼働していません。ElasticIPアドレスは間違っていないようです。関連付けもされています。
nginxとunicornは稼働しています。上手くnginxにデータを渡せていないのでしょうか。。。
「port 443: 接続を拒否されました」というエラー文を発見したのでnginxの設定をserver {listen 80 から listen 443}に変更してみたのですが今度はERR_SSL_PROTOCOL_ERRORに変わるのみです。

ここにより詳細な情報を記載してください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

nginx に関してのみ回答しますが、port 443 での listen ができていません。

nginxの設定をserver {listen 80 から listen 443}に変更してみたのですが今度はERR_SSL_PROTOCOL_ERRORに変わるのみです。

単純に変更しただけであれば、証明書の設定等が出来ていないせいでしょう。
nginx の基本を学習して、設定してください。

投稿2020/08/23 22:35

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問