即使没有防火墙,Nmap 扫描中 443 端口似乎也已关闭

即使没有防火墙,Nmap 扫描中 443 端口似乎也已关闭

我试图诊断一个问题,即对我的 VPS 的任何 HTTPS 请求都返回ERR_CONNECTION_CLOSED。我正在使用在 NGINX 上实现的 Let's Encrypt,而 Web 服务器本身是一个 Node.js 应用程序。

该网站在特定子域下提供服务,我们就这么说吧mysub.domain.com

以下是 Nmap 扫描的结果mysub.domain.com

443/tcp  open     https?

对公共 IP 地址进行类似扫描的结果如下:

443/tcp  closed   https

我的 VPS 还没有防火墙,至少主机本身没有。以下是iptables -S

-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT

更新以下是输出netstat -tlpdn

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      367/sshd        
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      7283/nginx -g daemo
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      773/mysqld      
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      7283/nginx -g daemo
tcp6       0      0 :::22                   :::*                    LISTEN      367/sshd        
tcp6       0      0 :::8080                 :::*                    LISTEN      5873/nodejs     

更新以下是 NGINX 的sites-available/default内容

server {
    listen 443 ssl;

    server_name mysub.domain.com;

    ssl_certificate /etc/letsencrypt/live/mysub.domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mysub.domain.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_stapling on;
    ssl_stapling_verify on;
    add_header Strict-Transport-Security max-age=15768000;

    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

server {
    listen 80;
    server_name mysub.domain.com;
    return 301 https://$host$request_uri;
}

VPS 所在设施的管理员告诉我,他们已经打开了 443 端口。他们是不是漏掉了什么?还是我的失误?

答案1

事实证明,管理员确实漏掉了一些事情。该设施实施了一些奇怪的 NAT/IP 转发器,他们忘记将端口 443 中的流量转发到我的 VPS。

相关内容