Install Nginx
$ sudo apt-get update
$ sudo apt-get install nginx
That’s it, Nginx is now installed and you can do the usual start, stop and restart with the following command:
$ service nginx start
$ service nginx stop
$ service nginx stop
Configure Nginx
Nginx is going to act like a reverse proxy for your domain. When a user types in your-domain, they are going to serves the pages from your-ip:4567. To do this, you will need to navigate to your configuration file.
$ cd /etc/nginx/sites-available/
Personally, I remove the configuration and create a new one.
$ rm default
$ nano default
Inside the configuration file I use the following:
server {
listen 80;
server_name domain.com;
location / {
root /var/www/nodebb;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4567/;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
You will need to change domain.com to your own domain name and the root path to wherever you installed NodeBB.