Correct way to forward traffic in nginx to node.js
I want to forward all traffic to a certain URL in nginx to node.js. I'm still new to node.js and I'm wondering if I should be usi开发者_如何学Cng some kind of CGI service (like PHP) or if I should setup a node.js server (like nginx -> apache) and forward all traffic through nginx to that server like below:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Node.js\n');
}).listen(8124, "127.0.0.1");
This is only a single page which needs to run a node.js script. What is the best way to do this?
Nginx reverse proxy (aka proxy_pass) doesn't support keep-alive. But it's possible to establish keep-alive connection for FastCGI using a 3rd party module, Maxim Dounin's Upstream Keepalive module.
By the way, Node.js is yet stable to run without any reverse proxy.
精彩评论