Google Cloud Storage – Load Balancer – Host and path rules

google-cloud-platformgoogle-cloud-storageload balancing

I have a website, with a Google Cloud Load Balancer, called santi.com

I have a Google Cloud Storage Bucket called santi-pictures

I have successfully setup a Host and path rule from this Load Balancer to this Bucket by entering this information in the Google Cloud Console.

+-----------+-------------+----------------+
| Hosts     | Paths       | Backends       |
+-----------+-------------+----------------+
| santi.com | /pictures/* | santi-pictures |
+-----------+-------------+----------------+

It works correctly when I access this url in the browser…

http://santi.com/pictures/me.jpg

as long as there is a picture in this location in the bucket:

gs://santi-pictures/pictures/me.jpg

But how can I change my load balancer configuration so that I can instead get this following picture when I use the url mentioned above:

gs://santi-pictures/me.jpg

This is already a pictures bucket, so it doesn't make sense to me to have to put a folder called pictures in it.

Thanks for your help.

Best Answer

I tested with following host and path rules and verified with http://load-balancer-ip/file-name and was able to access the file present within the root of the bucket defined in backend configuration of the load balancer.

| Hosts | Paths | Backends |

| WEB-SERVER-IP | /* | Backend-service-name |

Try copying the image within the root of the your bucket defined in backend configuration of Load balancer and add or change the "Host and path rules" to define path as "/*" (without quotes). You should be able to access the image using "gs://bucket-name/file-name" or "http://load-balancer-ip/file-name"

Hope it helps.

Related Topic