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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM