Multiple Target URLs

I am new to Tyk and I was wondering if someone could tell me if it is possible to set up multiple target urls under the same api.

In my current api configuration I have apis defined with multiple origins on the backend.

Ex:
publicly api.company.com/news --> origin newsapi.production.com/news
publicly api.company.com/news/staging --> origin newsapi.staging.com/news
publicly api.company.com/news/dev --> orign newsapi.dev.com/news

Is there a way to do this with the default configuration in the Gateway or if not specify multiple origins using the URL rewrite function?

Any help or guidance would be appreciated.

thanks,
Chris

Hi Chris,

I’m afraid not - Tyk API Definitions are 1 target per configuration, with an optional override per API Version.

I’d invert your URL scheme though:

publicly api.company.com/prod/news --> origin newsapi.production.com/news
publicly api.company.com/staging/news--> origin newsapi.staging.com/news
publicly api.company.com/dev/news--> orign newsapi.dev.com/news

Then you can just set up three API Definitions in Tyk.

Alternatively, use the domain bindings:

publicly api.company.com/news --> origin newsapi.production.com/news
publicly api.staging.company.com/news--> origin newsapi.staging.com/news
publicly api.dev.company.com/news--> orign newsapi.dev.com/news

Do you have more info on using domain bindings or a link to docs on the subject?

This is the main doc on the kinds of domain bindings supported:

https://tyk.io/docs/tyk-api-gateway-v-2-0/configuration/domains-and-domain-handling/

You can set a domain to bind to in the dashboard under the custom domain field, the binding will be domain+listen_path