Apache2在Cloudflare反向代理后 - “URL对Google不可用”获取失败:爬取异常
创始人
2024-09-05 07:32:02
0

当使用Apache2作为Web服务器,并通过Cloudflare进行反向代理时,可能会遇到"URL对Google不可用"或"获取失败:爬取异常"的错误。这通常是由于Cloudflare的安全策略导致的。

以下是解决此问题的一些可能方法,包含代码示例:

  1. 确保Apache2的日志级别设置为debug,以便更详细地查看错误日志。可以通过编辑Apache2的配置文件/etc/apache2/apache2.conf,将以下行添加到文件中:
LogLevel debug
  1. 在Apache2的虚拟主机配置中,添加mod_remoteip模块以解析真实的客户端IP地址。这可以通过编辑虚拟主机配置文件(通常是/etc/apache2/sites-available/000-default.conf)来完成,将以下行添加到标签中:
RemoteIPHeader CF-Connecting-IP
RemoteIPTrustedProxy 103.21.244.0/22
RemoteIPTrustedProxy 103.22.200.0/22
RemoteIPTrustedProxy 103.31.4.0/22
RemoteIPTrustedProxy 104.16.0.0/12
RemoteIPTrustedProxy 108.162.192.0/18
RemoteIPTrustedProxy 131.0.72.0/22
RemoteIPTrustedProxy 141.101.64.0/18
RemoteIPTrustedProxy 162.158.0.0/15
RemoteIPTrustedProxy 172.64.0.0/13
RemoteIPTrustedProxy 173.245.48.0/20
RemoteIPTrustedProxy 188.114.96.0/20
RemoteIPTrustedProxy 190.93.240.0/20
RemoteIPTrustedProxy 197.234.240.0/22
RemoteIPTrustedProxy 198.41.128.0/17
RemoteIPTrustedProxy 2400:cb00::/32
RemoteIPTrustedProxy 2606:4700::/32
RemoteIPTrustedProxy 2803:f800::/32
RemoteIPTrustedProxy 2405:b500::/32
RemoteIPTrustedProxy 2405:8100::/32
  1. 在Apache2配置文件中,添加以下部分以允许Cloudflare的IP地址通过Apache2的访问控制列表(ACL):

    Require all granted
    Allow from 103.21.244.0/22
    Allow from 103.22.200.0/22
    Allow from 103.31.4.0/22
    Allow from 104.16.0.0/12
    Allow from 108.162.192.0/18
    Allow from 131.0.72.0/22
    Allow from 141.101.64.0/18
    Allow from 162.158.0.0/15
    Allow from 172.64.0.0/13
    Allow from 173.245.48.0/20
    Allow from 188.114.96.0/20
    Allow from 190.93.240.0/20
    Allow from 197.234.240.0/22
    Allow from 198.41.128.0/17
    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

  1. 在Cloudflare的设置中,禁用"防火墙"和"爬虫"功能,以便允许Apache2与Google的爬虫进行通信。

这些方法应该有助于解决"URL对Google不可用"或"获取失败:爬取异常"的错误。请根据您的具体环境和需求进行调整和测试。

相关内容

热门资讯

【NI Multisim 14...   目录 序言 一、工具栏 🍊1.“标准”工具栏 🍊 2.视图工具...
银河麒麟V10SP1高级服务器... 银河麒麟高级服务器操作系统简介: 银河麒麟高级服务器操作系统V10是针对企业级关键业务...
不能访问光猫的的管理页面 光猫是现代家庭宽带网络的重要组成部分,它可以提供高速稳定的网络连接。但是,有时候我们会遇到不能访问光...
AWSECS:访问外部网络时出... 如果您在AWS ECS中部署了应用程序,并且该应用程序需要访问外部网络,但是无法正常访问,可能是因为...
Android|无法访问或保存... 这个问题可能是由于权限设置不正确导致的。您需要在应用程序清单文件中添加以下代码来请求适当的权限:此外...
北信源内网安全管理卸载 北信源内网安全管理是一款网络安全管理软件,主要用于保护内网安全。在日常使用过程中,卸载该软件是一种常...
AWSElasticBeans... 在Dockerfile中手动配置nginx反向代理。例如,在Dockerfile中添加以下代码:FR...
AsusVivobook无法开... 首先,我们可以尝试重置BIOS(Basic Input/Output System)来解决这个问题。...
ASM贪吃蛇游戏-解决错误的问... 要解决ASM贪吃蛇游戏中的错误问题,你可以按照以下步骤进行:首先,确定错误的具体表现和问题所在。在贪...
月入8000+的steam搬砖... 大家好,我是阿阳 今天要给大家介绍的是 steam 游戏搬砖项目,目前...