2

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

  • I have a website running on a Wordpress machine in a VM instance which I want users to access when they enter outairnet.com.

  • And I have a separate html file that I want users to access when they access outairnet.com/map.

  • WP is running on a compute engine VM, connected to a VM instance and to a backend service. The seperate html file is on a service bucket, connected to a backend bucket.

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?

ChrisF
  • 134,786
  • 31
  • 255
  • 325
Amir Yaari
  • 43
  • 4
  • 1
    try path as `/map/*` and visit `outairnet.com/map/whatever.html` – Asdfg May 06 '21 at 15:42
  • 1
    In addition of @Asdfg solution, can you put your file in the path `/map/` in the bucket? – guillaume blaquiere May 06 '21 at 16:21
  • tried doing both things. now outairnet.com takes the user to the WP on the VM which is good. but anything else outairnet.com/whatever - gives a 404 not found – Amir Yaari May 07 '21 at 11:36
  • 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 – Amir Yaari May 08 '21 at 12:38

2 Answers2

2

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.

Wojtek_B
  • 4,245
  • 1
  • 7
  • 21
  • i've tried all of the above but still get page not found when accessing outairnet.com/map or outairnet.com/whatever. – Amir Yaari May 07 '21 at 14:58
  • 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 – Amir Yaari May 08 '21 at 12:39
0

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

Amir Yaari
  • 43
  • 4