我已经看到很多人们推荐的帖子nginx
或类似于前端 Web 服务器的node.js
.
由于 node 具有创建 web 服务器的能力,例如:
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' );
问:在什么情况下,除了 node 之外,您还需要另一个 Web 服务器?