假如Nginx有两个server配置如下:
server {
listen 80;
listen 443;
server_name a.xxx.com;
ssl on;
ssl_certificate /path/server.crt;
ssl_certificate_key /path/server.key;
...
}
server {
listen 80;
listen 443;
server_name b.xxx.com;
#以下没有ssl相关的配置
...
}
curl 访问 a.xxx.com 时会提示:Closing connection 0 curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to a.xxx.com:443
原因在于第2个server配置中,监听了443端口,却没有ssl的相关设置(ssl、ssl_certificate、ssl_certificate_key)
所以,在监听了443端口的配置中,一定要做ssl的相关设置
另外,通过追加请求头方式的https访问,会导致匹配到默认ssl段
curl -v -k -H "Host: xxx.yyy.com" https://10.10.10.10/
* Trying 10.10.10.10...
* TCP_NODELAY set
* Connected to 10.10.10.10 (10.10.10.10) port 443 (#0)
curl -v -k https://xxx.yyy.com/
* Trying 10.10.10.10...
* TCP_NODELAY set
* Connected to xxx.yyy.com (10.10.10.10) port 443 (#0)
注意 * Connected to 部分的不同。