Nginx不允许域名访问,仅允许ip+端口方式访问
server {
listen 46295;
server_name _;
if ($host != "公网ip") {
return 444; # nginx自己的状态码,在客户端显示为empty response
}
root /var/www/html;
index index.html;
}
web中间件都可以用类似的方法处理,检查Host是否为ip,不是ip做状态码返回