This post will show how to create a simple HTTP proxy using NodeJS and Express. This simple proxy dispatches the caller's request to the target server only if the called endpoint is allowed or whitelisted. In the code below to whitelist an endpoint, it has to be written in the whitelist array. The whitelist array accepts Express URL patterns documented here http://expressjs.com/api.html#app.use
These 20 lines of code took me about 4 hours to put together, so I thought I save the hassle for whoever comes after me.
This simple proxy can be expanded to also act as a security gateway, the calling user had to be authenticated before his request is dispatched to the target server. This can be done easily using express by adding the code snippet below to the top of the whitelist code.
The technique above can be expanded more and more to handle multiple business requirements.