仅允许 cloudflare i.p 范围通过 .htaccess 给出 403 错误
Allowing only cloudflare i.p range through .htaccess giving 403 error
我一直试图在我的服务器上只允许 cloudflares i.p 范围,但我一直收到 403 错误,403 是绕过 cloudfare 的人应该看到的
我试过了
#cloudflare
order deny,allow
Deny from all
#ipv4
allow from 173.245.48.0/20
allow from 103.21.244.0/22
allow from 103.22.200.0/22
allow from 103.31.4.0/22
allow from 141.101.64.0/18
allow from 108.162.192.0/18
allow from 190.93.240.0/20
allow from 188.114.96.0/20
allow from 197.234.240.0/22
allow from 198.41.128.0/17
allow from 162.158.0.0/15
allow from 104.16.0.0/12
allow from 172.64.0.0/13
allow from 131.0.72.0/22
#ipv6
allow from 2400:cb00::/32
allow from 2606:4700::/32
allow from 2803:f800::/32
allow from 2405:b500::/32
allow from 2405:8100::/32
allow from 2a06:98c0::/29
allow from 2c0f:f248::/32
我试过了
DenyAllButCloudFlare
我遇到了同样的问题,上面一行给出了 500 错误
我这辈子都弄不明白,cloudflare 支持只是让我转到我关注的白名单页面
我正在使用 Apache 2.4.2
编辑:更改了 Apache 版本号 :)
尝试在 Apache 中使用 Require 指令。 Apache 自己提到:
The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use.
尝试将其更改为,并确保 mod_authz_host 已启用:
#path to your website
<Directory "path/to/public_html/or/var/www/html">
#ipv4
Require ip 173.245.48.0/20
Require ip 103.21.244.0/22
Require ip 103.22.200.0/22
Require ip 103.31.4.0/22
Require ip 141.101.64.0/18
Require ip 108.162.192.0/18
Require ip 190.93.240.0/20
Require ip 188.114.96.0/20
Require ip 197.234.240.0/22
Require ip 198.41.128.0/17
Require ip 162.158.0.0/15
Require ip 104.16.0.0/12
Require ip 172.64.0.0/13
Require ip 131.0.72.0/22
#ipv6
Require ip 2400:cb00::/32
Require ip 2606:4700::/32
Require ip 2803:f800::/32
Require ip 2405:b500::/32
Require ip 2405:8100::/32
Require ip 2a06:98c0::/29
Require ip 2c0f:f248::/32
</Directory>
查看 https://httpd.apache.org/docs/2.4/howto/access.html 了解更多信息。
注意这一点:Cloudflare 自己说:我认为无论如何只使用普通的 Apache 指令应该更好
Cloudflare no longer updates and supports mod_cloudflare, starting with versions Debian 9 *and *Ubuntu 18.04 LTS of the Linux operating system. We now support mod_remoteip for customers using Apache web servers. Customers who are interested in building the mod_cloudflare package can download the codebase from GitHub.
而且mod_remoteip感觉很没有安全感。所以,我建议你坚持使用 Require ip 指令。
我一直试图在我的服务器上只允许 cloudflares i.p 范围,但我一直收到 403 错误,403 是绕过 cloudfare 的人应该看到的
我试过了
#cloudflare
order deny,allow
Deny from all
#ipv4
allow from 173.245.48.0/20
allow from 103.21.244.0/22
allow from 103.22.200.0/22
allow from 103.31.4.0/22
allow from 141.101.64.0/18
allow from 108.162.192.0/18
allow from 190.93.240.0/20
allow from 188.114.96.0/20
allow from 197.234.240.0/22
allow from 198.41.128.0/17
allow from 162.158.0.0/15
allow from 104.16.0.0/12
allow from 172.64.0.0/13
allow from 131.0.72.0/22
#ipv6
allow from 2400:cb00::/32
allow from 2606:4700::/32
allow from 2803:f800::/32
allow from 2405:b500::/32
allow from 2405:8100::/32
allow from 2a06:98c0::/29
allow from 2c0f:f248::/32
我试过了
DenyAllButCloudFlare
我遇到了同样的问题,上面一行给出了 500 错误
我这辈子都弄不明白,cloudflare 支持只是让我转到我关注的白名单页面
我正在使用 Apache 2.4.2
编辑:更改了 Apache 版本号 :)
尝试在 Apache 中使用 Require 指令。 Apache 自己提到:
The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use.
尝试将其更改为,并确保 mod_authz_host 已启用:
#path to your website
<Directory "path/to/public_html/or/var/www/html">
#ipv4
Require ip 173.245.48.0/20
Require ip 103.21.244.0/22
Require ip 103.22.200.0/22
Require ip 103.31.4.0/22
Require ip 141.101.64.0/18
Require ip 108.162.192.0/18
Require ip 190.93.240.0/20
Require ip 188.114.96.0/20
Require ip 197.234.240.0/22
Require ip 198.41.128.0/17
Require ip 162.158.0.0/15
Require ip 104.16.0.0/12
Require ip 172.64.0.0/13
Require ip 131.0.72.0/22
#ipv6
Require ip 2400:cb00::/32
Require ip 2606:4700::/32
Require ip 2803:f800::/32
Require ip 2405:b500::/32
Require ip 2405:8100::/32
Require ip 2a06:98c0::/29
Require ip 2c0f:f248::/32
</Directory>
查看 https://httpd.apache.org/docs/2.4/howto/access.html 了解更多信息。
注意这一点:Cloudflare 自己说:我认为无论如何只使用普通的 Apache 指令应该更好
Cloudflare no longer updates and supports mod_cloudflare, starting with versions Debian 9 *and *Ubuntu 18.04 LTS of the Linux operating system. We now support mod_remoteip for customers using Apache web servers. Customers who are interested in building the mod_cloudflare package can download the codebase from GitHub.
而且mod_remoteip感觉很没有安全感。所以,我建议你坚持使用 Require ip 指令。