简体   繁体   English

NodeJS网站的反向代理

[英]Reverse proxy for a NodeJS website

I look for a reverse proxy for my NodeJS website. 我正在为我的NodeJS网站寻找反向代理。 I thought of Varnish or nginx or something else. 我想到了VarnishNginx或其他东西。

What would you suggest me and why (do not necessarily focus on Varnish vs nginx )? 您会向我提出什么建议?为什么(不一定要专注于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. nginx可能是最好的独立解决方案,但是,当我使用Node.js时,我宁愿将所有内容都保留在Node.js中,因此我不必担心(相对简单)的配置。 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. 我个人使用了node-reverse-proxy ,它允许我只在一个简单的应用程序中指定一些简单的路由,然后将其路由回各个应用程序。

This is the node-reverse-proxy sample code: 这是node-reverse-proxy示例代码:

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 . 您可能会发现nginx更适合您的需求,但就个人而言,对于简单的反向代理设置,我更喜欢node-reverse-proxy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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