nginx 设置只能通过域名访问,禁止通过ip访问 实测效果: 方法: 在ngnix的配置文件nginx.conf中,增加如下判断: if ($host != '域名'){ return 444; } 具体位置: