【发布时间】:2017-12-13 05:16:17
【问题描述】:
我正在更新我的原始问题,因为我对引用字符串中包含的主机名混淆了“不需要主机”。
所以我现在需要确定什么。在 Apache 2.2 中,我执行以下操作来允许/拒绝某些 ip 范围、用户代理和域名/引用者。
这是一个非常简短的示例,因为我不想给任何人增加太多代码的负担。我已经测试了 Apache 2.4 代码块,它看起来工作正常,但现在是正确的做事方式吗?
是否有必要像我以前一样指定列入白名单的 IP 和域,还是只需要因为 Require all granted 而将其列入黑名单??
只要加载了 mod_access_compat 模块,旧的 2.2 方法就可以在 Apache 2.4 上 100% 工作,但显然在不使用兼容性模块的情况下为 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>
【问题讨论】:
-
Require host查看远程客户端的主机(通过反向 IP 查找),而不是Referer标头。看起来你误解了它的用途。 -
谢谢格雷厄姆,这解释了它,我确实把它误认为是引荐来源字符串中的主机。
-
我已经更新了我原来的问题,以更好地解释我想用新的 Apache 2.4 访问控制语法实现什么
标签: apache mod-access