CloudFlare 导致 GCP CloudRun 和存储桶出现 return 404 http 代码

CloudFlare causing GCP CloudRun and storage bucket to return 404 http code

我试图在前面有 Cloudflare 的 Google 云平台上托管一个简单的云 运行 应用程序。我一直在所有页面上收到 404,因此放弃并转而使用存储桶,因为它是一个简单的静态网站。

Cloudflare 指向负载均衡器静态外部 IP 地址。

我现在遇到了完全相同的问题。我有一个负载均衡器指向具有静态内容的 GCP 存储桶。启用 Cloudflare 后,它会为所有页面提供 404 错误。关闭 Cloudflare,它工作正常。

这可能是什么原因?

我需要在 Cloudflare 端启用完整的 SSL

为了防止在 Cloud 运行 落后于 Cloudflare 时收到 404,您需要在 Cloud 运行 上使用您使用的域创建“域映射”(以便 Host headers 匹配),或者您需要使用 Cloudflare Page Rules 中的主机 Header 重写功能(可能是 pro/enterprise 功能)将 header 设置为 运行 服务的 *. run.app url.

无论哪种情况,请参阅注释on this page,即:

For example, if you are using Cloudflare CDN, you should turn off the "Always use https" option in the "Edge Certificates" tab of the SSL/TLS tab.