Reputation: 5977
I have two services running Cloud Run
such as api1
and api2
.
I set up a global external HTTP(S) load balancer (classic)
in GCP to route the path to both services.
such as
Paths | Action | Backend |
---|---|---|
/api1/* | Route traffic to a single backend | service-api1 |
/api2/* | Route traffic to a single backend | service-api2 |
When I send a request mydomain/api1/aaa/ccc/
, api1
get the request url as mydomain/api1/aaa/ccc/
When I send a request mydomain/api2/ddd/eee/
, api2
get the request url as mydomain/api2/ddd/eee/
Is there a way to rewrite the incoming request for api1
, so that api1
will see the request as mydomain/aaa/ccc/
?
This also apply to api2
, so api2
will see the request as mydomain/ddd/eee/
From the Rewrite documentation,
The load balancer provides the following mutually exclusive primary actions:
- Reads the incoming URL in the request.
- 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.
I think there is a way, but I don't manage to make it work.
Any advice?
Upvotes: 1
Views: 1328
Reputation: 5977
In load balancing console page
Advanced host and path rule (URL redirect, URL rewrite)
in Host and path rules
When you send a request mydomain/api1/aaa/ccc/
, api1
will see the request as mydomain/aaa/ccc/
.
Upvotes: 2