我有一个运行ubuntu和nginx 0.8.4的ec2实例,虚拟主机使用http服务几个不同的域,但是一个使用SSL / https。
安全域configuration:
server { listen 443 ssl; server_name "securedomain.tld"; ssl_certificate /etc/nginx/certs/securedomain.tld.crt; ssl_certificate_key /etc/nginx/certs/securedomain.tld.key; if ($host != $server_name) { return 444; # this won't work because HTTPS communication has # been already started, warning message is displayed } // ... }
不安全的域configuration:
server { listen 80; server_name "unsecuredomain.tld"; // ... }
现在,使用https服务的域名正在赶上所有的https域名,对于所有的托pipe域名…这意味着https://unsecuredomain.tld/将显示一个警告,实际上从securedomain.tld
问题是,有没有办法阻止nginx提供所有使用https服务的不安全域? 例如通过指定您只想接受给定请求主机的https连接…
提示:ec2实例不能有多个受影响的IP。
简而言之:不。 就nginx而言,你已经告诉它,到端口443的所有连接都是该虚拟主机的SSL连接,并且只是按照你所说的去做。 在请求中可以看到Host:头部时,SSL协商已经完成(缺lessSNI,如果您已经获得所有域的证书并且正在被SNI感知浏览器)。
作为womble笔记,SSL不匹配警告是没有第二个IP地址或某种代理设置是不可预知的。
如果要防止通过SSL提供unsecuredomain.tld内容,则应在securedomain.tld SSL vhost定义中使用类似以下内容的内容,而不是使用以下内容:
if ($host != $server_name) { rewrite ^(.*)$ http://unsecuredomain.tld permanent; }
只是反popup来,而不是在他们已经收到浏览器警告并select继续之后抛出一个不同的HTTP错误。