Use subdomain to route requests

Hey there,

I have a doubt if it’s possible to use subdomain to route a service.

My set is:

api.example.com (A - IPv4 Address) -> kong-load-balancer.aws.elb.aws… (Kong Load balancer, created with AWS CloudFormation)

I need to call my service, let’s say service1, but I would like to register it as subdomain service1.api.example.com, instead of using api.example.com/service1.

Is that a way to do that?

Thanks in advance

If I am reading this correctly you would like to declare a service with a subdomain in its host name? I do not see any issues with that. in the URL option of a service resource when creating just do http://service1.api.example.com/ for example.

Now if you want your gateway hostname to support routing based on a fresh subdomain on the gateway itself Kong does not do that that I am aware of now.(ex: service1.kong-gateway.company.com/). And I see it really as an aesthetic and not a functional need?

Yes, would be aesthetic! Thanks for the answer!

Hello @thiagoretondar

I’ve a different interpretation of your post from @jeremyjpj0916 which could be wrong. If so, please ignore this post.

Here’s what I understand:
You’ve a Kong cluster running at api.example.com and now you want to transform service1.api.example.com to api.example.com/service1.

You could point CNAME your service1.api.example.com to api.example.com and then have a Kong routing rule to route all requests with Host as service1.api.example.com to a service http://upstream/service1 .

1 Like

Hi @Thaigoretondar,

I’m actually hoping you can help me with just getting SSL routed through to see our GUI dashboard and proxy URL. Did you setup a 443 listener and 8444 target group? or is there something else you need to do to get traffic through?

Hi when using subdomain should it be set in the host parameter when creating kong service or is this set in the host in kong route. I am using the latest kong 1.1. Thanks.