简体   繁体   中英

Reverse proxy for a NodeJS website

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 )?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM