大网数据广告活动
服务器运维问答

Failed to connect to server port 443: Connection refused

· 52CE 我爱测

I have a web server running on my server at 127.0.0.1:8088 And I want to access it from internet. Output of ss -nplut with running web server : tcp LISTEN 0 1024 127.0.0.1:8088 0.0.0.0:* users:(("ctprods",pid=2042,fd=9)) Output s…

问题原文

原帖链接 · C Taque · CC BY-SA 4.0

I have a web server running on my server at 127.0.0.1:8088 And I want to access it from internet.

Output of ss -nplut with running web server :

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

Output ss -nplut |grep 443

tcp LISTEN 0 511 *:443 *:*

I created an apache virtual host (site enabled, apache reloaded) :

<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 omitted]

    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>

I created an ssl certificate with lets encrypt :

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

I have an A record in my dns provider for ctprods.cyprientaque.com pointing to my server IP

But when I try to access to my server with curl, I get an error :

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

And I cannot see the request tcpdump port 443..

已采纳解答

原帖链接 · Gerald Schneider · CC BY-SA 4.0

Your Apache is not listening on port 443. You configured your VirtualHost only for HTTP, not fot HTTPS. Configure a second VirtualHost with Port 443 and your certificates and make sure you have a Listen 443 directive in your Apache config. Your certificates don't belong in the :80 VirtualHost.

The above was based on wrong information in the question. Whatever you did in the meantime, your server is now rechable via HTTPS.

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-08-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。