我设法用LE创build了我的证书,没有错误,我也设法将我的stream量从端口80redirect到端口443.但是当我重新加载我的nginx服务器时,我无法访问我的网站。 Ngnix错误日志显示以下行:
4 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 192.168.0.104, server: 0.0.0.0:443
我想这意味着它找不到证书,然后导航到证书的path,他们都在那里,可能是什么问题? 下面是我的Ngnixconfiguration的样子:
server { listen 80; server_name pumaportal.com www.pumaportal.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name pumaportal.com www.pumaportal.com; add_header Strict-Transport-Security "max-age=31536000"; ssl_certificate /etc/letsencrypt/live/pumaportal.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/pumaportal.com/privkey.pem; ssl_stapling on; ssl_stapling_verify on; access_log /var/log/nginx/sub.log combined; location /.well-known { alias /[MY PATH]/.well-known; } location / { proxy_pass http://localhost:2000; 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; proxy_set_header X-Forwarded-For $remote_addr; } }
这一切似乎很简单,我不明白问题在哪里。
运行nginx之后 – 这一切似乎都没问题:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
我的猜测是你有另一台服务器在端口443上侦听。这个服务器没有定义ssl_certificate,并且它被自动select(SNI)。 尝试从/ etc / nginx / sites-enabled中删除所有的符号链接,除了这个服务器要做的工作(如果可能的话,否则检查所有的服务器聆听443而不正确configuration)。
我在今天早些时候解决了这个问题,所以我在这里要澄清CA的观点(事后做的很好,现在理解了这个问题),你很可能有两个服务器块(我没有足够的评论点):
#默认
服务器{
listen 443 default_server;
服务器名称 _;
#...
}
#real网站
服务器{
听443 ssl;
服务器名称 ;
#...
}
SNI只能匹配那些标有ssl监听器的SNI。 默认服务器将抓取443上的所有传入stream量,不pipe是否SSL。 因此,它实际上是在实际上使得SNI从蝙蝠的实际工作中解脱出来。
症状:
nginx -t和服务重载) 解决scheme:
我今天早上解决了这个问题,删除了默认的服务器块,因此允许SNI在SSL监听器上匹配。
可选的解决scheme是将ssl监听器和ssl_certificate行添加到服务器块,以便在默认主机上启用SNI。 你仍然会得到SSL错误,所以这不是最好的解决scheme,但它会让你的SNI工作:)
像往常一样迟到,但是因为它帮助我…检查crt是否是畸形的。 当build立“统一”的crt(crt +中级),做
$cat server.crt provider.intermediate > unified.crt
我不知何故失去了一个LF,并得到了这样一条线:
—–结束证书———- BEGIN CERTIFICATE —–
代替
—–结束证书—–
—– BEGIN CERTIFICATE —–
而nginx将不会拿到证书,并失败与上述错误。
干
# openssl x509 -in unified.cert -text -out
给了我openssl的线索会出错。
检查您的证书文件权限是否正确。 请发布目录列表( ls -la )