温馨提示×

如何查看debian nginxssl状态

小樊
46
2026-09-17 20:59:08
栏目: 云计算

在 Debian 上查看 Nginx 的 SSL/TLS 状态,可以从配置是否启用、证书是否有效、运行时是否监听 HTTPS、以及实际握手情况几个层面来检查。下面按常用方法说明:


一、查看 Nginx 是否已启用 SSL 配置

1. 查看 Nginx 配置文件

sudo nginx -T

重点看是否有:

listen 443 ssl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;

2. 检查站点配置

ls /etc/nginx/sites-enabled/
sudo cat /etc/nginx/sites-enabled/default

二、检查 Nginx 是否正在监听 443 端口

sudo ss -tulnp | grep :443

sudo netstat -tulnp | grep :443

有输出说明 Nginx 已在监听 HTTPS。


三、检查 SSL 证书状态(有效期)

1. 使用 openssl 查看证书信息

echo | openssl s_client -connect yourdomain.com:443 2>/dev/null | openssl x509 -noout -dates -subject

示例输出:

notBefore=May  1 00:00:00 2024 GMT
notAfter=May  1 23:59:59 2025 GMT
subject= /CN=yourdomain.com

2. 本地证书文件检查

openssl x509 -in /etc/ssl/certs/yourcert.pem -noout -dates

四、检查 Nginx SSL 配置是否正确(语法 & 测试)

sudo nginx -t

输出应类似于:

nginx: configuration file /etc/nginx/nginx.conf test is successful

五、查看实际 HTTPS 访问状态(推荐)

1. curl 测试

curl -I https://yourdomain.com

2. 查看 SSL 协议与套件

curl -v https://yourdomain.com

3. 在线工具(外部)

  • https://www.ssllabs.com/ssltest/
  • https://www.sslshopper.com/ssl-checker.html

六、查看 Nginx 错误日志(排错用)

sudo tail -f /var/log/nginx/error.log

常见 SSL 错误:

  • SSL_CTX_use_PrivateKey_file → 证书/私钥不匹配
  • cannot load certificate → 路径错误或权限不足

七、查看使用的 TLS 协议版本

nmap --script ssl-enum-ciphers -p 443 yourdomain.com

总结速查表

目的 命令
查看配置 nginx -T
检查端口 `ss -tulnp
检查证书 openssl s_client -connect domain:443
测试配置 nginx -t
查看日志 tail /var/log/nginx/error.log

如果你愿意,可以告诉我:

  • 域名或 IP
  • 是否使用 Let’s Encrypt
  • 想查的是 配置状态 / 证书状态 / 握手状态

我可以给你更精确的检查命令。

0