嗨,我遇到了一个超级奇怪的问题。
每当我在 Facebook 上发布指向我的网站的链接时,它们都会显示为“禁止访问”。
该网站本身运行良好,在其他网站上链接时我没有看到这一点。
这可能是服务器配置错误吗?有什么想法去哪里看吗?
这里有一些信息:
我有一个运行 WHM 11.25.0 的专用服务器
我有 2 个使用 cPanel 11.25.0 托管的网站
错误消息:
禁止
你没有 访问权限 /blog/deepwater-horizon-11/ 关于此 服务器。
此外,还有一个 404 遇到未找到错误 尝试使用 ErrorDocument 来 处理请求。
Apache/2.2.14(Unix) mod_ssl/2.2.14 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 服务器位于 www.offshoreinjuries.com 80端口
更新:
这里有一个示例链接(如果有帮助的话)。 (注意直接进入链接页面效果很好)
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.offshoreinjuries.com%2Fblog%2Fdeepwater-horizon-11%2F&h=834ea
更新和答案:
找到了问题并在下面添加了完整的答案。
您必须在某个地方有一个规则来读取 HTTP_REFERER 并拒绝来自 Facebook 的传入链接。严重地。这就是字里行间发生的事情:
telnet www.offshoreinjuries.com 80
HEAD /blog/deepwater-horizon-11/ HTTP/1.1
Host: www.offshoreinjuries.com
HTTP/1.1 200 OK
Date: Fri, 28 May 2010 09:19:45 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.12
X-Pingback: http://www.offshoreinjuries.com/blog/xmlrpc.php
Content-Type: text/html; charset=UTF-8
200 好的,很好。
telnet www.offshoreinjuries.com 80
HEAD /blog/deepwater-horizon-11/ HTTP/1.1
Host: www.offshoreinjuries.com
Referer: http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.offshoreinjuries.com%2Fblog%2Fdeepwater-horizon-11%2F&h=834ea
HTTP/1.1 403 Forbidden
Date: Fri, 28 May 2010 09:21:04 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Content-Type: text/html; charset=iso-8859-1
403 禁止,不好。
telnet www.offshoreinjuries.com 80
HEAD /blog/deepwater-horizon-11/ HTTP/1.1
Host: www.offshoreinjuries.com
Referer: http://alvaro.es/
HTTP/1.1 200 OK
Date: Fri, 28 May 2010 09:20:36 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.12
X-Pingback: http://www.offshoreinjuries.com/blog/xmlrpc.php
Content-Type: text/html; charset=UTF-8
200 再次确定。
您的服务器正在主动拒绝来自 Facebook 的访问者。
我终于能够查出这种行为的真相了。
我的主机 HostGator 的默认 mod_security 设置包括一组白名单和黑名单。检查这些后,我发现
.facebook.com/l.php
已列入黑名单。我通过从 mod_security 黑名单中删除
.facebook.com/l.php
解决了我的问题,但是我也可以通过在 WHM 中单击一下将我的 mod_security 设置重置为默认值(相对于 HostGator 配置)。
如果您使用WAF,您需要将Facebook爬虫IP范围列入白名单。
您可以从以下位置找到 IP 范围:
whois -h whois.radb.net -- '-i origin AS32934' | grep ^route
在 IP 集中添加 IP 范围,并添加规则以允许来自 IP 集。