apache2.4禁止IP访问

发布时间 2023-06-07 16:05:00作者: 见欲不见

如果在apache2.4想禁止使用ip访问,只能通过域名访问
https是改这个配置文件
conf/extra/httpd-ssl.conf

http是改这个
conf/extra/httpd-vhosts.conf

将下面这个配置的111.111.111.111修改为你对应的服务器IP
复制到配置文件最尾部
重启apache服务即可
http的根据需要修改端口

<VirtualHost *:443>
ServerName 111.111.111.111
ServerAlias *
DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">
Require all granted