Amir Yaari
Amir Yaari

Reputation: 53

Configuring Google Cloud Load Balancer path rules

I'm trying to configure the Google Cloud loadbalancer to do the following:

I've triedd to configure a very simple path forwarding rule, which made sense to me. But it just adds up to anyone trying to access outairnet.com/* gets to the WP (which is fine) but accessing outairnet.com/map doesn't point to the storage bucket with the html file, however accessing outairnet.com/index.html does point to the separate html file.

My LB config looks like this.


I think I'm on to the problem but still can't solve it.

it looks like google console adds a /* rule even when I try to delete it.

so its a /* path rule that catches everything despite having a more specific rule like /mypath/* in addition.

but after removing it is just readded automatically for some reason. why?

Upvotes: 2

Views: 965

Answers (2)

Amir Yaari
Amir Yaari

Reputation: 53

I just added another path rule with just "/" directing to the VM and it seemed to do it, but now the only glitch is www.outairnet.com/map is fine but outairnet.com/map without www directs to the vm and not the bucket

Upvotes: 0

Wojtek_B
Wojtek_B

Reputation: 4443

It's possible - there are a few steps involved such as creating a bucket with your static page, adding it as a backend service in your load balancer and creating a new path-rule in it to redirect the requests.

And now the details:

  1. Create a new bucket - pick the name you like (outairnet-static or something that will be meaningful to you so you don't delete by accident). You can ignore all the tutorials telling that it has to have the exact name of your domain - since it will only be hosting a file accessible under outairnet.com/mylink/ it will work regardless of the name used. I tested it.
  2. Create a directory in your bucket named exactly ax the path under which you want it to be. If you want outairnet.com/mylink/ then directory's name has to be mylink. Upload your files into that directory. Name your main index file index.html unless you want to provide full file path.
  3. Make the bucket avaialble to everyone.
  4. Go to your LB configuration and edit backend services; add a new backend bucket.

enter image description here

  1. Go to your Host and Path Rules and configure a new path; Enter the name of your site and the path (Remember that the path value must be /mylink/*.) and select the bucket you've just created from the dropdown list.

enter image description here

No changes necessary for the frontend. Save the changes and in a few moments it should be working.

Upvotes: 2

Related Questions