サーバーポート 443 への接続に失敗しました: 接続が拒否されました

サーバーポート 443 への接続に失敗しました: 接続が拒否されました

私のサーバーでは 127.0.0.1:8088 で Web サーバーが稼働しており、インターネットからアクセスしたいと考えています。

実行中のWebサーバーでのss -nplutの出力:

tcp LISTEN 0 1024 127.0.0.1:8088 0.0.0.0:* users:(("ctprods",pid=2042,fd=9))

出力 ss -nplut |grep 443

tcp LISTEN 0 511 *:443 *:*

Apache 仮想ホストを作成しました (サイトが有効、Apache がリロードされています) :

<VirtualHost *:443>
 # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName cyprientaque.com
    ServerAlias ctprods.cyprientaque.com

    ServerAdmin [email protected]

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.

#       RewriteCond %{SERVER_NAME} =ctprods.cyprientaque.com
#       RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

     <Proxy *>
             Require all granted
     </Proxy>
             ProxyPass / http://127.0.0.1:8088/
             ProxyPassReverse / http://127.0.0.1:8088/

SSLCertificateFile /etc/letsencrypt/live/ctprods.cyprientaque.com-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ctprods.cyprientaque.com-0001/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Let's Encrypt を使用して SSL 証明書を作成しました:

Certificate Name: ctprods.cyprientaque.com-0001
Serial Number: 39538aec7472a644e8d22887f858de17177
Domains: ctprods.cyprientaque.com
Expiry Date: 2020-11-17 10:59:58+00:00 (VALID: 89 days)
Certificate Path: /etc/letsencrypt/live/ctprods.cyprientaque.com-0001/fullchain.pem
Private Key Path: /etc/letsencrypt/live/ctprods.cyprientaque.com-0001/privkey.pem

私のDNSプロバイダーには、ctprods.cyprientaque.comのAレコードがあり、私のサーバーIPを指しています。

しかし、curl を使用してサーバーにアクセスしようとすると、エラーが発生します。

$ curl -X GET https://ctprods.cyprientaque.com/projects
curl: (7) Failed to connect to ctprods.cyprientaque.com port 443: Connection refused 

また、tcpdump ポート 443 の要求を確認できません。

答え1

Apache はポート 443 をリッスンしていません。VirtualHost は HTTP 専用に設定されており、HTTPS 専用ではありません。ポート 443 と証明書を使用して 2 番目の VirtualHost を設定し、Listen 443Apache 構成にディレクティブがあることを確認してください。証明書は VirtualHost に属していません:80

上記は質問内の誤った情報に基づいています。その間に何をしたかに関係なく、サーバーは HTTPS 経由でアクセス可能になりました。

$ curl -X GET https://ctprods.cyprientaque.com/projects
"Invalid JWT"

関連情報