nginx禁用来自vps ip的访问,

nginx禁用来自vps ip的访问,,nginx,Nginx,这是我的nginx集,当我在浏览器中进入我的域时,它工作正常,但如果我写我的vps ip,它也工作正常,我如何禁用直接ip访问?提前谢谢 服务器{ 服务器名称example.com www.example.com; 地点/{ 代理通行证http://localhost:3000; proxy_http_版本1.1; 代理设置头升级$http\U升级; 代理集头连接“升级”; 代理设置头主机$Host; 代理缓存绕过$http\u升级; } 侦听443 ssl;#由Certbot管理 ssl_c

这是我的nginx集,当我在浏览器中进入我的域时,它工作正常,但如果我写我的vps ip,它也工作正常,我如何禁用直接ip访问?提前谢谢

服务器{
服务器名称example.com www.example.com;
地点/{
代理通行证http://localhost:3000;
proxy_http_版本1.1;
代理设置头升级$http\U升级;
代理集头连接“升级”;
代理设置头主机$Host;
代理缓存绕过$http\u升级;
}
侦听443 ssl;#由Certbot管理
ssl_certificate/etc/letsencrypt/live/example.com/fullchain.pem;#由Certbot管理
ssl_certificate_key/etc/letsencrypt/live/example.com/privkey.pem;#由Certbot管理
include/etc/letsencrypt/options-ssl-nginx.conf;#由Certbot管理
ssl_dhparam/etc/letsencrypt/ssl-dhparams.pem;#由Certbot管理
}
服务器{
如果($host=www.example.com){
返回301 https://$host$request\u uri;
}#由Certbot管理
如果($host=example.com){
返回301 https://$host$request\u uri;
}#由Certbot管理
听80;
服务器名称example.com www.example.com;
返回404;#由Certbot管理
}
阅读答案。