1.步骤 这样设置可以防止ip地址暴露出去,增强网站的安全性 打开nginx的配置文件,下面是原先的80端口的配置文件 记得把配置中80端口后面的default_server删掉,不然重新加载的时候会报错
server {
	listen 80 default_server; //这里的default_server要删除
	server_name www.sulvblog.cn;
	
	location / {
		root /home/public;
		index index.html index.htm;
	}
}
我们的做法是新加一个80端口配置,新增的配置这里default_server要保留
server {
  listen 80 default_server; //这里的default_server要保留
  server_name _;
  return 403;
}
配置完后重新加载nginx配置文件
sudo nginx -s reload
然后在网页输入ip地址时,会出现如下界面,表示设置成功
912sy.com download resources are from the network, only for learning and reference use, the copyright belongs to the original author, do not use for commercial purposes, please remove yourself within 24 hours after downloading.
If the content published on this site inadvertently violates your rights and interests, please contact us and the site will be deleted within one business day.If you encounter any problems please contact customer service QQ:2385367137
912sy " Nginx only allows domain access to disable ip access