1

防止 HTTPS 暴露服务器上绑定的域名

 2 years ago
source link: https://vzlogs.com/prevent-https-from-exposing-the-domain-name-bound-on-the-server/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

防止 HTTPS 暴露服务器上绑定的域名

当我们使用 CloudFlare 等 CDN 服务时,除了有节约流量、加速访问的功能之外,还有一项重要的功能是防止暴露网站的真实 IP。但如果你的 NGINX 没有正确的配置,则使用 HTTPS 协议直接访问服务器的 IP,就会暴露出指向服务器上的一个域名的证书,从而被一些扫描全网 IP 地址的服务获取到域名与 IP 的对应关系。

例如,服务器 IP 为 1.1.1.1,上面绑定了两个网址:a.com、b.com。a.com 和 b.com 都使用了 CDN 服务,直接访问 https://a.com 获取到的是 CDN 的网址,例如 2.2.2.2。但若真实服务器上 NGINX 未配置正确,则攻击者访问 https://1.1.1.1,就会显示出 a.com 的证书,从而获取 a.com 的真实服务器 IP。

有很多种方式来规避此问题,例如生成假证书来配置到 NGINX 的默认网站上,但较为繁琐。从 NGINX 1.19.4 版本开始,可以配置一个默认 HTTPS 服务器,并将 ssl_reject_handshake 参数设置为 on 即可解决。

server {
listen 443 default_server;
server_name _;
ssl_reject_handshake on;
}



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK