需要在nginx.conf中增加以下片段,然后重启nginx服务即可 # 禁止通过ip地址访问 http服务 server { listen 80 default_server; server_name _; return 400; } # 禁止通过ip地址访问https服务 server { listen 443 ssl default_server; ssl_certificate xxx.xxx.com.pem; ssl_certificate_key xxx.xxx.com.key; server_name _; return 400; }
nginx 禁止通过IP地址访问,只能通过域名访问
最新推荐文章于 2024-05-05 07:02:44 发布