Just want to verify I understand how Proxying works in Kong

(wherever you see “ttp://” it means “http://”, I had to replace it since new users can’t add more than 5 links in a message :slight_smile: )

Hi,

There’s something about how proxying works in Kong that I think I understand but still not 100% sure, would be great if someone here can verify it for me.

So, let’s say I have a service with the url ttp://myservice.com, and I want to expose one API from this service: /reports/{reportid}/status

meaning that the behavior i’m looking for is that given that my Kong address is ttp://my.kong.com, then if a client will access to ttp://my.kong.com/reports/50/status then Kong will proxy the request to ttp://myservice.com/reports/50/status.

from my understanding I have only 2 options how to apply such behavior in Kong:

  1. create a service with the url “ttp://myservice.com/reports/50/status” and then assign a route with the path “/reports/50/status” to this service/
  2. use the enterprise transformer plugin / write my own customized transformer plugin.

am I right?

There ISN’T an option (without any plugins) to create a service with the url “http://myservice.com” and assign a route to it with the path “/reports” and then everything that will be matched to this route will be forwarded using THE SAME REQUEST PATH, as in:
ttp://my.kong.com/reports/aaa/bbb --> ttp://myservice.com/reports/aaa/bbb
ttp://my.kong.com/reports/ccc?key=value --> ttp://myservice.com/reports/ccc?key=value
and so on, all using only one service and one route attached to it.

Did i get it right? Am I missing anything?

Thanks!

Ok, I think I’m actually wrong and in order to achieve what i need to do is:

  1. create a service with the url “http://myservice.com
  2. assign a route to this service with the url “/reports” AND strip_path=False

now every request to http://my.kong.com/requests// will be redirected to myservice.com/reports//

Right?

@EB123 Hi,

You should be able to achieve that by disabling the strip_path attribute of a Route (which is enabled by default). E.g.

service.url = http://myservice.com
route.paths = ["/reports"]
route.strip_path = false

This way, requests to http://my.kong.com/reports/anything will be proxied to http://myservice.com/reports/anything.

You can read moer about proxying behavior and the strip_path attribute in the Proxy Guide, which is an essential read for all new Kongers :slight_smile:

Best,

Yeah, after a whole day of digging in the documentation I figured it out about half an hour after posting my question :grin:

But thanks anyway!