Imported Google Group message.
Date:Thursday, 18 June 2015 08:50:45 UTC+1.
Tyk is really quite flexible when it comes to how you want to configure your gateway. In your case it sounds like you would like to use Tyk in the "API Gateway pattern" sense instead of as a network software appliance (which is how it norally deployed).
The way Tyk works is that it uses something called a listen_path to route requests to the appropriate upstream API, so if you had a microservice architecture with three api's (api1.someserver.com, api2.anotherserver.com and api3.yetanotherserver.com lets call them), then Tyk could be set up to proxy those three apis in a few ways, here's a few scenarios:
Option 1 - Raw Gateway
Tyk Gateway application on it's own - this means not using the host manager, and just letting tyk act as a proxy, assume tyk is running on tyk.mygateway.com, now out of the box it will do the following when you add those APIs to it's configuration, for conveniences sake, we are asuming you are seting the listen_path manually and not letting it be set by the dashboard (which would assign a UUID):
http://tyk.mygateway.com/api1/* -> api1.someserver.com/*
http://tyk.mygateway.com/api2/* -> api2.anotherserver.com/*
http://tyk.mygateway.com/api3/* -> api3.yetanotherserver.com/*
Not the upstream API URL's can be arbitrary, so long as the base path is correct.
This scenario suits your miscroservice architecture well, since the listen paths are configurable you can set up a nice unified URL structure for your whole API group as a whole. Remember that API policies and keys can grant access to multiple upsream APIs with global rate limits, so one key can now be granted access to all three APIs.
Option 2 - Use the host manager
The host manager in 1.6 is pretty powerful, all it does is create and destroy nginx configuration (server) blocks and manage an nginx process, so now you can do domain routing - for example if you have many APIs and want to expose them seperately - the server blocks provide a way to map subdomains or directory locations to upstream, this is what Tyk does by default if you use the docker script, it would manage the above using api_slug values (the listen path here is set to a UUID to ensure there are no routing conflicts), the route now would look like:
http://api.domain.com/* -> http://tyk.mygateway.com/api1/* -> api1.someserver.com/*
http://api2.domain.com/* -> http://tyk.mygateway.com/api2/* -> api2.anotherserver.com/*
http://api3.domain.com/* -> http://tyk.mygateway.com/api3/* -> api3.yetanotherserver.com/*
This may seem really arbitrary, but the thing is we do not want the Tyk gateway to be a web server, and think that routing, url rewrites, etc. should be left to bits of software that do it better than we would, hence the host manager being slaved to NginX.
This scenario is what you are describing, and is what the quickstart will set up as (it's an all inclusive demo after all) but now there is a third way which is coming in 1.7 and is used by Tyk Cloud for it's routing (mainly because wildcard SSL certificates for subdomains of subdomains are almost impossible):
Option 3 - (v1.7)
Here the host manager has been upgraded to allow per-organisation API server block manipulation, as in, instead of having one-server-block-per-api, we actually have one-server-block-per-organisation, and now you can have something like this:
http://api.organisation-name.domain.com/api1/* -> http://tyk.mygateway.com/api1/* -> api1.someserver.com/*
http://api.organisation-name.api.domain.com/api2/* -> http://tyk.mygateway.com/api2/* -> api2.anotherserver.com/*
http://api.organisation-name.api.domain.com/ais3/* -> http://tyk.mygateway.com/api3/* -> api3.yetanotherserver.com/*
The real power here comes from being able to manage many organisations (and their respecitve APIs) with a single installation, and since the nginx blocks are actually just templates that use the go tempalte syntax, they are entirely configurable to whatever set up your company has.
We've tried to make sure that Tyk is as a whole really flexible, and with a bit of grit almost any kind of set up can be achieved, and with the upgrade to the host manager I just described, it becomes even more powerul.
I hoep that answers the question
- show quoted text -