I\'ve set up Node.js and Nginx on my server. Now I want to use it, but, before I start there are 2 questions:
I made a repository in Github which you can clone, vagrant-node-nginx-boilerplate
basically the node.js app at /var/www/nodeapp
is
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(4570, '127.0.0.1');
console.log('Node Server running at 127.0.0.1:4570/');
and the nginx config at /etc/nginx/sites-available/
is
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/nodeapp;
index index.html index.htm;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:4570;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}