3
votes

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.

2
Did you try adding the hostname manually instead of using the ´*´? As I can see from the issue description, that you are using the host rule ´*´ instead of a specific host. See the attached document for more details on it.Nur
@Nur Yup, but no luckDipen Dedania

2 Answers

2
votes

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.

0
votes

Google now offers URL rewriting which can achieve this.