I am testing a sample node app using nginx.
But I get 504 Gateway Time-out. nginx/1.4.6 (Ubuntu 14.04)
Below is the procedure which I followed for installing node, nginx on Azure.
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
curl -Lo hello.js http://do.co/node-hello
sudo nano app.js
app.js file
var http = require('http');
http.createServer(function (req, res) {
console.log('Came here');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/');
ls -l
-rwxrwxrwx 1 root root 265 Mar 12 15:52 app.js
sudo npm install pm2 -g
pm2 startup
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup upstart -u azureuser --hp /home/azureuser
pm2 start app.js
Nginx Server
sudo apt-get update
sudo apt-get install nginx
sudo nano /etc/nginx/sites-available/default
sudo nano /etc/nginx/sites-available/default file
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name testingnode.cloudapp.net;
location / {
proxy_pass http://13.65.148.35:8080;
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;
}
}
sudo service nginx restart
http port 80 is opened in azure dashboard
So after all configurations trying to run http://13.65.148.35/ or testingnode.cloudapp.net will give 504 timeout.
Please let me if anything needs to be configured for running node with nginx.
via Sharath
No comments:
Post a Comment