Usage For Full Web Page In Addition To Standard API Type Requests

Imported Google Group message. Original thread at: Redirecting to Google Groups Import Date: 2016-01-19 21:07:37 +0000.
Sender:Russell Holloway.
Date:Friday, 13 March 2015 19:14:17 UTC.


I was wondering if anyone has experience with or knowledge of if it’s feasible to also use tyk simply as a reverse proxy for other web servers (in addition to api gateway). We have some tools where we need the API gateway functionality, but some where we really just need a full reverse proxy. If we can manage all through the same system, that would be good.

I can easily set it up so a request will be proxied through tyk and to the destination web server. However, the challenge I face is how to make it do the necessary rewrites for subsequent requests (CSS files, javascript, etc). These requests essentially all need to be rerouted through /<api_id>/css/…, /<api_id>/js/…, etc. but each request (beyond the original made by user) is missing <api_id>. Unless I’m mistaken, transforms didn’t seem like the way to do that as they are really meant for transforming incoming data into a somewhat static (with variables) output template.

I was thinking serving on subdomain would fix that issue as the requests would simply be proxied to the target path but not modified further (similar to ProxyPass/ProxyPassReverse on Apache), but am not sure if that is still option via dashboard.

Anyone know how this could be done?


Imported Google Group message.
Sender:Martin Buhr.
Date:Saturday, 14 March 2015 00:30:47 UTC.

Hi Russ,

I’m afraid we’ll have to disappoint you, in order for something like that to work we’d need to build in URL rewriting capabilities into Tyk, Tyk uses the listen paths (the api ID) to detect which api rules should be applied to the request, so that data is required for it to work properly.

There is one option, set strip_listen_path to false, this will preserve the api id part of the path in the outbound request, so your app could, if the URLs are relative, see this path and request assets via Tyk.

However, this means that Tyk will request endpoints with the Apiid in the path. Might be worth a try, you’ll need to see how t behaves as it could get weird :slight_smile: