每个虚拟主机的nginx sslconfiguration

我正在将configuration从单个主机切换到nginx服务器上的多个虚拟主机。 直到我的更改,ssl工作正常,但添加几个虚拟主机,每个具有独特的域名和 – 因此,不同的证书,ssl不希望工作。

我原来的configuration是:

# fragment of nginx.conf file http { # ... ssl_certificate_key /path/to/privkey.pem; ssl_certificate /path/to/fullchain.pem; ssl_dhparam /path/to/dhparam; # ... } 

所以,这是nginx服务器的单个证书。

添加几个虚拟主机后,我希望他们为他们的域提供自己的,正确的证书。 所以我从主nginx.conf文件中删除了所有与ssl相关的参数,并将它们添加到虚拟主机文件中:

 # fragment of sites-enabled/my.server.com file server { listen 443 ssl; root "/var/www/my.server.com/"; server_name my.server.com www.my.server.com; location / { try_files $uri $uri/ /index.html; } ssl_certificate_key /path/to/my/server/com/privkey.pem; ssl_certificate /path/to/my/server/com/fullchain.pem; ssl_dhparam /path/to/my/server/com/dhparam; } 

重新加载nginx后,我无法连接到这些虚拟主机:

 # curl https://my.server.com curl: (35) gnutls_handshake() failed: The TLS connection was non-properly terminated. # openssl s_client -connect my.server.com:443 CONNECTED(00000003) 140524682454680:error:140790E5:SSL routines:ssl23_write:ssl handshake failure:s23_lib.c:177: --- no peer certificate available --- No client certificate CA names sent --- SSL handshake has read 0 bytes and written 305 bytes --- New, (NONE), Cipher is (NONE) Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE No ALPN negotiated SSL-Session: Protocol : TLSv1.2 Cipher : 0000 Session-ID: Session-ID-ctx: Master-Key: Key-Arg : None PSK identity: None PSK identity hint: None SRP username: None Start Time: 1488541876 Timeout : 300 (sec) Verify return code: 0 (ok) --- 

对我来说,它看起来像一个nginx无法find/读取证书文件,但情况并非如此,因为path是完全相同的configuration没有虚拟主机。

看了/var/logs/nginx/error.log我也发现这行:

 *39 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking 

我相信这是一个非常小而愚蠢的东西,我失踪了。 任何人都可以看到我做错了什么?

事实certificate,至less有一个启用的虚拟主机绑定到443端口,没有正确configurationssl( ssl_certificate_keyssl_certificate参数缺失)。

我不知道为什么,但nginx没有抱怨这个,而是 – 其他虚拟主机被打破。