Apache 存取限制 禁止訪問特定檔 防止日誌 壓縮包被下載

apache安全配置-禁止訪問特定檔,防止日誌、壓縮包被下載,Apache禁止訪問目錄列出檔清單

1. Apache禁止訪問目錄列出檔清單

步驟如下:

找到
<Directory /> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Require all denied
</Directory>

將
Options Indexes FollowSymLinks

修改為:
Options FollowSymLinks

2. 禁止訪問特定檔 防止日誌 壓縮包被下載

禁止訪問 .txt
<Files ~ ".txt">
	Require all denied
</Files>

允許訪問 ads.txt
<Files ~ "ads.txt">
	Require all granted
</Files>

3. 存取限制語法

1. apache 2.4 存取限制的語法不同於 apache 2.2,舉例如下:
   1. 限制所有存取
      2.2 configuration:
      Order deny,allow
      Deny from all

      2.4 configuration:
      Require all denied

   2. 允許所有存取
      2.2 configuration:
      Order allow,deny
      Allow from all

      2.4 configuration:
      Require all granted

   3. 允許所有在 deyu.wang 網域的主機存取
      2.2 configuration:
      Order Deny,Allow
      Deny from all
      Allow from deyu.wang

      2.4 configuration:
      Require host deyu.wang

2. apache 2.4 以 ip 限制存取的語法可適用 ipv6,當然也還適用 ipv4:
   1. 完整 ip
      Require ip 18.1.2.3
      Require ip 192.168.1.140 192.168.1.141

   2. 部分 ip,允許指定網段。
      Require ip 18.1
      Require ip 18 172.20 192.168.2

   3. 網段/遮罩,允許指定網段。 A network/netmask pair:
      Require ip 18.1.0.0/255.255.0.0
   
   4. 網段/遮罩數字,允許指定網段。
      Require ip 18.1.0.0/16
期待您的留言

Comments

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *