Skip to content

Instantly share code, notes, and snippets.

@adnanfajr
Last active August 4, 2017 09:20
Show Gist options
  • Save adnanfajr/f18325e1b5682ebaf6a97e6c840ec70c to your computer and use it in GitHub Desktop.
Save adnanfajr/f18325e1b5682ebaf6a97e6c840ec70c to your computer and use it in GitHub Desktop.
nginx conf for Express JS and Socket IO on Ubuntu 16.04
server {
listen 80;
listen [::]:80;
server_name your-domain.name;
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_pass http://your-domain.name:3000; # if your socket run on port 3000
}
}
# install pm2
sudo npm install -g pm2
# start app
pm2 start Server.js
# stop app
pm2 stop Server.js
# start app as server boot up
pm2 startup systemd
## replace your-username with your user login
sudo su -c "env PATH=$PATH:/opt/node/bin pm2 startup systemd -u your-username --hp /home/your-username"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment