Mr J
Mr J

Reputation: 2973

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

I was trying to host a simple Cloud Run application on Google Cloud Platform with Cloudflare in front of it. I kept getting 404s on all pages so gave up and switched to using buckets because it's a simple static website.

Cloudflare is pointing to the load balancer static external IP address.

I'm now encountering the exact same issue. I have a load balancer pointing to a GCP bucket with static content. With Cloudflare on, it serves up a 404 error for all pages. With Cloudflare off, it works fine.

What could be the cause of this?

Upvotes: 0

Views: 1066

Answers (2)

ahmet alp balkan
ahmet alp balkan

Reputation: 45302

To prevent getting 404s when Cloud Run is behind Cloudflare, you need to either create a "Domain Mapping" on Cloud Run with the domain you use (so that Host headers match), or you need to use Host Header Rewrite feature in Cloudflare Page Rules (might be a pro/enterprise feature) to set the header to Run service's *.run.app url.

In either case, see the note on this page, that is:

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.

Upvotes: 1

Mr J
Mr J

Reputation: 2973

I needed full SSL turned on at Cloudflare's end

Upvotes: 2

Related Questions