加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

如何告诉nginx仅为一个vhost管理的域提供https?

发布时间:2020-12-13 21:24:59 所属栏目:Nginx 来源:网络整理
导读:我有一个运行ubuntu和nginx 0.8.4的ec2实例,vhost使用http服务几个不同的域,但使用SSL / https服务. 安全域配置: server { listen 443 ssl; server_name "securedomain.tld"; ssl_certificate /etc/nginx/certs/securedomain.tld.crt; ssl_certificate_key

我有一个运行ubuntu和nginx 0.8.4的ec2实例,vhost使用http服务几个不同的域,但使用SSL / https服务.

安全域配置:

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
    }

    // ...
}

不安全的域配置:

server {
    listen 80; 
    server_name "unsecuredomain.tld";

    // ...
}

现在,使用https服务的域正在赶上所有管理域的所有https流量…这意味着https://unsecuredomain.tld/将显示警告并实际提供来自securedomain.tld的内容:(

问题是,有没有办法阻止nginx提供使用https服务的所有不安全域?例如,通过指定您只想接受给定请求主机的https连接…

提示:ec2实例不能有多个IP受影响.

最佳答案
简而言之:不.就nginx而言,你已经告诉它所有与端口443的连接都是该虚拟主机的SSL连接,而它只是按照你所说的去做.当它在请求中看到Host:标头时,SSL协商已经完成(没有SNI,如果您获得所有域的证书并且受到SNI感知的打击,那么这实际上只会有所帮助浏览器).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读