Hi,
I am creating an API proxy router with openresty and I want to know best approach.
My solution right now looks like this:
A GUI generates a JSON document that basically points routes to endpoints. For example:
GET api.myproxy.com/users/{id} -> internal-oauthserver.mydomain.com/users/{id}
Instead of generating all the routes into a static Nginx conf, because I have to restart Nginx every time I change routes I am thinking of putting all routes into Redis.
So Redis will map all possible routes defined in the JSON document by importing the JSON into Redis. Or if the GUI can access Redis directly I will just edit the Redis records.
Every time Nginx gets a request, lua with will look into Redis to see if there is a match on that route, if there is it will proxy the data back and forth. If there is no match it will return an error message.
Is this a good approach? Thanks.
If this has been done already it would be nice to get a hold of that code.