How to create multiple service with custom routes

I have few endpoints (microservices) and i want to give them a custom routes.

For example: I have user service and location service and I want those routes in kong looks like this:

GET http://localhost:8001/service/user/list --> http://user-service-url.com/user_list

GET http://localhost:8001/service/location/122332--> http://location-service-url.com/get/122332

when user go to http://localhost:8001/service/user/list from kong it should get the contents from http://user-service-url.com/user_list, same goes to second service.

Is this possible to achieve in kong ? if it is how ? I couldn’t find anything regarding this.

Thanks

Hi @spmsupun,

I think that is not possible in Kong Community with any of the out of the box plugins. In Kong EE you can use Request Transformer Advanced plugin to replace the URI forwarded to upstream, but It’s not available in the Community version.

One thing that should work is to use a custom Serverless Pre-function enabled at each Route, using the Openresty directives to set uri, like that:

https://openresty-reference.readthedocs.io/en/latest/Lua_Nginx_API/#ngxreqset_uri

Regards

Actually this is quite possible, I was looking at kong in wrong way. I didn’t know it work as nginx(sort of). so after few days of struggling before I go crazy I figure it out :sweat_smile:
this is very simple actually, you can control this using route path.
create a service for your api and create a route and set path as the path you want user to user to request, thats it.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ