apache或nginx禁止通过ip访问
apache
<VirtualHost *:443>
ServerName 服务器IP
<Location />
Order Allow,Deny
Deny from all
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerName 服务器IP
<Location />
Order Allow,Deny
Deny from all
</Location>
</VirtualHost>
nginx
......
listen 443 ssl http2;
server_name www.a.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/html;
if ($host != 'www.a.com'){
return 403;
}
#www.a.com是域名
......
也可以新增一个server:
server{
server_name xxx.xxx.xxx.xxx;
return 403; ##或者直接返回403 或者 rewrite ^(.*) http://wwwbaidu.com permanent; ##强制跳转到指定的网址
}

浙公网安备 33010602011771号