Centos7.6 Apache 虚拟机禁止访问IP,允许访问多域名多个虚拟目录设置

存放配置文件路径 /etc/httpd/conf.d
自定义命名,配置文件后缀格式确保 *.conf
注:这是两个配置文件,也是两种方法。

# 一个WEB目录
# 禁止以IP地址形式访问
<VirtualHost 192.168.8.129> ServerName 192.168.8.129 <Location /> Order Allow,Deny Deny from all </Location> </VirtualHost>
# 允许通过域名形式访问,指定路径 <VirtualHost 192.168.8.129> DocumentRoot /var/www/html/nav.jackcui.com/ ServerName nav.jackcui.com </VirtualHost>
# 多个虚拟目录
# 禁止以IP地址形式访问
<VirtualHost 192.168.8.129> ServerName 192.168.8.129 <Location /> Order Allow,Deny Deny from all </Location> </VirtualHost> # 允许通过域名形式访问,多个虚拟指定路径
<VirtualHost 192.168.8.129> Alias /lam /usr/share/ldap-account-manager Alias /phpldapadmin /usr/share/phpldapadmin/htdocs Alias /ldapadmin /usr/share/phpldapadmin/htdocs Alias /pwd /var/www/html
<Directory /usr/share/ldap-account-manager> Options +FollowSymLinks AllowOverride All Require all granted DirectoryIndex index.html </Directory>

<Directory /var/lib/ldap-account-manager/tmp> Options -Indexes </Directory>
<Directory /var/lib/ldap-account-manager/tmp/internal> Options -Indexes Require all denied </Directory>
<Directory /var/lib/ldap-account-manager/sess> Options -Indexes Require all denied </Directory>
<Directory /var/lib/ldap-account-manager/config> Options -Indexes Require all denied </Directory>
<Directory /usr/share/ldap-account-manager/lib> Options -Indexes Require all denied </Directory>
<Directory /usr/share/ldap-account-manager/help> Options -Indexes Require all denied </Directory>
<Directory /usr/share/ldap-account-manager/locale> Options -Indexes Require all denied </Directory> <Directory /usr/share/phpldapadmin/htdocs> <IfModule mod_authz_core.c> # Apache 2.4 Require all granted </IfModule>
#
<IfModule !mod_authz_core.c> # Apache 2.2 # Order Deny,Allow # Deny from all # Allow from 127.0.0.1 # Allow from ::1 # </IfModule> </Directory>
ServerName ldap.jackcui.com
</VirtualHost>

猜你喜欢

转载自www.cnblogs.com/jackcui/p/11489100.html