Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

path based configuration in GCP load balancer

I'm working on sort of prototype project. I have two micro services hosted on separate server with different tech stack. Here are some of the endpoints of it

1 User management
    -- /users
    -- /user/:id
    -- /user/roles
2 Other operations (e.g. managing a book, book details)
    -- /books
    -- /book/:id
    -- /book/:id/history

I'm using GCP for hosting my apps. I have one load balancer pointing to above backend services. I'm trying to use Host and path rules to use both services and it looks like below screenshot. enter image description here

I would like to access my User management micro service as

dns/user-manager/users
dns/user-manager/user/:id
dns/user-manager/user/roles

and other micro service as

dns/book-manager/books
dns/book-manager/book/:id
dns/book-manager/book/:id/history

but it looks like, it just forwarding above url to particular service directly, so I'm getting 404. And I don't want to add all my routes to load balancer path settings as it will be difficult to maintain. Looking forward to hear some solutions. Thanks in advance.

like image 523
Dipen Dedania Avatar asked Oct 28 '25 13:10

Dipen Dedania


1 Answers

I understand you want inbound requests to /user-manager/SUB/PATH to be forwarded to user-service and re-written to /SUB/PATH. It sounds like you have got the forwarding to work, but not the rewriting.

Google HTTP/S LB can't do the re-writing for you. You will have to add a reverse-proxy between GCLB and your microservice to rewrite the URLs. For example nginx can do this.

like image 62
David Avatar answered Oct 30 '25 12:10

David