Reputation: 5133
I look for a reverse proxy for my NodeJS website. I thought of Varnish or nginx or something else.
What would you suggest me and why (do not necessarily focus on Varnish vs nginx)?
Upvotes: 1
Views: 656
Reputation: 7270
nginx
would probably be the best stand-alone solution, however, when I'm working with Node.js, I prefer to keep everything in Node.js so I don't have to worry about the (relatively simple) configuration. I personally use node-reverse-proxy
, which allows me to just specify some simple routes in a simple application, and then route it back to the individual applications.
This is the node-reverse-proxy
sample code:
var node_reverse_proxy = require('node-reverse-proxy');
var ip = '127.0.0.1';
var reverse_proxy = new node_reverse_proxy({
'first_host.com' : ip + ':8082',
'my.second_host.com' : ip + ':8081',
'my.second_host.com/page/' : ip + ':8080',
'' : ip + ':8080' // catch all other routes
});
reverse_proxy.start(80);
You might find that nginx
better suits your needs, but personally, for a simple reverse proxy setup, I do prefer node-reverse-proxy
.
Upvotes: 1