nginx配置
upstream nodejs {
server 127.0.0.1:3000;
}
server
{
listen 80;
server_name localnode.com;
error_log logs/localnode-error.log;
location / {
proxy_pass http://nodejs;
}
}
server.js
var http = require("http");
http.createServer(function(requrest, response){
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
浏览器访问 localnode.com:8888/+(目录/文件) 即可
网友评论