我有nginx与以下vhosts:
一个gitlab虚拟主机:
server { listen 443; server_name gitlab.mydomain.com; # eg, server_name source.example.com; server_tokens off; # don't show the version number, a security best practice root /home/git/gitlab/public; ssl on; ssl_certificate /etc/nginx/ssl/gitlab.crt; ssl_certificate_key /etc/nginx/ssl/gitlab.key; ... # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; ... }
默认虚拟主机来捕获所有其他域名
server { listen 80; return 444; } server { listen 443; return 444; }
但是现在如果去gitlab.mydomain.com,我只能得到
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.
没有其他的。 没有默认规则,每个*.mydomain.com也可以访问gitlab.mydomain.com 。 这是无法接受的。
如何configurationnginx,它只响应configuration的名称?
您的默认端口443服务器不知道任何证书,因此你得到这个错误,因为它不能做无SSL的SSL。 最好是在http部分(或每个需要SSL的服务器部分)中定义ssl *行,然后在每个服务器部分的端口443和ssl上使用您正在寻找的相同路由。