【发布时间】:2017-02-20 21:02:21
【问题描述】:
在 cloudflare 之前,我可以访问 phpMyAdmin 链接,例如
example.com/ctrl/pmasetup
在 CloudFlare 之后,我得到一个 403(来自我自己的 apache 服务器,而不是 CloudFlare 的错误页面)
Forbidden
You don't have permission to access /ctrl/pmasetup on this server.
我觉得我需要在服务器的某处添加 CloudFlare 的反向代理,我在 /etc/hosts 中做过,现在看起来像:
127.0.0.1 localhost localhost.localdomain
104.25.68.32 example.com <- This is the ip of my site when CloudFlare is enabled on it
我还在虚拟主机配置中的httpd.conf 中添加了它:
<VirtualHost *:80>
ServerAdmin support@example.com
DocumentRoot /var/www/example.com
ServerName example.com
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log combinedio
Alias /ctrl /var/www/ctrl
<Location /ctrl>
<RequireAny>
Require all denied
Require ip {my ip}
Require ip 104.25.68.32 <- CloudFlare IP, again
</RequireAny>
</Location>
#Header always set Access-Control-Allow-Origin "http://example.com"
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "*"
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
</VirtualHost>
编辑:即使在评论整个 RequireAny 块时,启用 CloudFlare 时我仍然会收到 403。
编辑 2:如果在 location 标签内我只有 Require all granted,那么它可以工作。那么,除了我最初放置的几个 IP,我怎么能禁止所有人呢?
编辑 3:这很可能是因为 CloudFlare 将您的 IP 更改为访问者,然后我的 apache 配置无法识别它。有什么想法吗?
【问题讨论】:
-
安装mod_cloudflare,保持旧的工作规则。如果他们将范围添加到 ips,请务必更新您的配置
-
... 如果您无法安装 mod_cloudflare,请改为检查
CF-Connecting-IP标头,但仅查看REMOTE_ADDR是否在范围内ip 页面,因此请准备好创建大量规则(您可以为禁止的RewriteRule设置大量的RewriteCond。
标签: apache .htaccess virtualhost cloudflare