我更新我的原始問題,因爲我混淆了「要求不主機」的引用字符串中包含的主機名。移動到新的Apache 2.4訪問控制語法
所以我需要確保現在。在Apache 2.2中,我做了以下操作來允許/拒絕某些IP範圍,用戶代理和域名/引用。
這是一個非常簡短的例子,因爲我不想讓任何代碼太多。我已經測試了Apache 2.4代碼塊,它看起來工作正常,但是現在正在做的事情是正確的嗎?
是否有必要指定列入白名單的IP和域名,因爲我之前正在做或僅僅因爲Require all granted
而只需要黑名單?
舊2.2方法在Apache 2.4上運行100%,只要mod_access_compat模塊被加載,但明顯地爲Apache 2.4做正確的事情而不使用兼容性模塊是一等獎。
的Apache 2.2:
<Directory /var/www/html>
Order Allow,Deny
Allow from all
Allow from env=good_bot
Allow from env=good_ref
Allow from 131.253.24.0/22
Allow from 131.253.46.0/23
deny from 104.197.51.76
deny from 108.167.189.81
deny from env=bad_bot
deny from env=spam_ref
</Directory>
的Apache 2.4:
<Directory /var/www/html>
<RequireAny>
<RequireAll>
Require all granted
Require not ip 104.197.51.76
Require not ip 54.242.250.203
Require not env bad_bot
Require not env spam_ref
</RequireAll>
<RequireAny>
Require ip 131.253.24.0/22
Require ip 131.253.46.0/23
Require env good_ref
Require env good_bot
</RequireAny>
</RequireAny>
</Directory>
「要求主機」查看遠程客戶端的主機(通過反向IP查找),而不是「Referer」頭。看起來你錯誤地解釋了它的用途。 –
感謝格雷厄姆,解釋它,我確實誤認爲引用字符串中的主機。 – MitchellK
我已經更新了我的原始問題,以更好地解釋我試圖用新的Apache 2.4訪問控制語法實現的內容 – MitchellK