how to add subpath to the incoming request URL automatically from load balancer in GCP

393 Views Asked by At

We have docker VMs under GCP Loadbalancer which gets traffic with URL abc.test.com/EMC.

Now we want user to only enter abc.test.com and expecting GCP LB to add this subpath (/EMC) and then route it to the VM instance group backend.

So in short, abc.test.com --> abc.test.com/EMC from load balancer I have checked the LB routing rules, redirect rules but didn't find anything which would suit our need(might have been possible with ingress, but we do not have that) or I might be missing something as I am not an expert in networking. Is it possible to do ?

Below are my LB settings for path rule and Frontend configuration

enter image description here

enter image description here

1

There are 1 best solutions below

3
On

I think you could do this with URL rewriting if I remember correctly. I got the following quote from Google's documentation, where I think number 2 is specifically what you are trying to accomplish.

The HTTP(S) Load Balancing URL rewrite feature:

  1. Reads the incoming URL in the request.
  2. Replaces the host, the path, or both the host and the path, transforming the URL before directing traffic to the backend service or backend bucket

Another page from Google's documentation shows you how to exactly accomplish such a thing with a GCP loadbalancer, independent of the kind of backend you are using.