I can't find a way to set up Google's Cloud Storage load balancer's host path and rules to point different domains to their corresponding folders in a single bucket.
I have two domains: foo.com and bar.com and I have a bucket with two folders in it: foo/
and bar/
. I want foo.com to serve files from the foo/
folder and bar.com to serve files from the bar/
folder.
I only see options to point specific domain paths to different buckets (e.g. foo.com/bar/ pointing to another bucket) but not different hosts/domains to different paths in bucket. How can I set up the rules to achieve this?
You need to use the advance feature of HTTPS load balancer and especially the URL prefix rewrite.
For that, you need to configure your host and path rules in advanced mode. Then, for the default access (without specific domains), you can redirect (URL REWRITE) to the /default folder of the backend.
Add host and path, and for foo.com, redirect to the folder /foo
by rewriting the prefix
Do the same for bar.
Wait 5 minutes (let the Load Balancer to advertise the POP), and enjoy :)