Reputation: 1450
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.
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.
Upvotes: 4
Views: 3364
Reputation: 81
in the routing rules
, choose the advance host and path rule
button. then in the path mathcer
box put somthing like this.
defaultService: projects/{project}/global/backendServices/{backend-a}
name: matcher1
routeRules:
- matchRules:
- prefixMatch: /dev/
priority: 1
routeAction:
weightedBackendServices:
- backendService: projects/{project}/global/backendServices/{backend-b}
weight: 100
urlRewrite:
pathPrefixRewrite: /
hostRewrite: {domain}
it will redirect your path {domain}/dev/test to {domain}/test on backend-b
Upvotes: 0
Reputation: 9721
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.
Upvotes: 2