webserver - node.js front end web server -


i have seen lots of posts people recommending nginx or similar front end web server node.js.
since node has ability create web server, such as:

var http = require('http'); var static = require('node-static'); var file = new static.server(); var url = require('url');  var index = require('./serverjs/index.js'); var login = require('./serverjs/login.js'); var admin_index = require('./serverjs/admin_index.js'); var admin_login = require('./serverjs/admin_login.js');  http.createserver(function (req, res) {     if (url.parse(req.url).pathname == '/index') {         index.serve(req, res);     } else if (url.parse(req.url).pathname == '/login') {         login.serve(req, res);     } else if (url.parse(req.url).pathname == '/admin/index') {         admin_index.serve(req, res);     } else if (url.parse(req.url).pathname == '/admin/login') {         admin_login.serve(req, res);     } else {         file.serve(req, res);     } }).listen(9000 , '127.0.0.1' ); 


q: in case scenario need web server in adition node's?

a front-end nginx more efficient @ serving static assets.

a front-end nginx useful if wanted run multiple backend servers, node.js combined apache/php node.js serves routes , apache/php serves other routes.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -