空主机头防范主要是防止别人恶意将域名解析到服务器IP上。
配置示例
方式一,增加vhost
# http的空主机头防范
server {
listen 80 default;
server_name _;
return 404;
}
# httos的空主机头防范
# ssl证书随便写一个已存在的即可
server {
listen 443 ssl;
server_name _;
ssl_certificate ../cert/rainux/123456_rainux.cn.pem;
ssl_certificate_key ../cert/rainux/123456_rainux.cn.key;
return 404;
}
方式二,if判断
if ($server_name != example.com) { return 403 }
标签:return,name,ssl,主机,server,nginx,防范,rainux
From: https://www.cnblogs.com/XY-Heruo/p/17010138.html