node和nginx组合那些事
作者:HerryLo
本文永久有效链接: https://github.com/AttemptWeb/Record…
对于前端开发,了解nodejs和nginx是有必要的。前端开发者自己构建项目时,更多的是自己使用nodejs+mongoDB搭建后端接口,使用nginx作为反向代理服务器。
为何选用nginx?对于前端来说,我觉得它是便于学习的,方便配置的。
下面是node和nginx组合的一点心得。
nodejs
nodejs搭建简易的前端服务接口
const http = require('http');
http.createServer(function(request, response){
response.writeHead(200, { 'Content-Type': 'text-plain' });
response.end('Hello World\n');
}).listen(1234);
nodejs可以提供接口和服务,在前端开发中,完全可以满足我们的需要。但我们将node服务部署到服务器时,那么我们就此时就需要用到代理服务器。