Server: Nginx
Configure Nginx to serve your application
Config File
Create .conf file
Create Nginx config file for nesula.ifactory.co:
$ sudo touch /etc/nginx/sites-available/nesula.ifactory.co.conf
Edit .conf file
Open .conf file in Nano editor:
$ sudo nano /etc/nginx/sites-available/nesula.ifactory.co.conf
Paste .conf file contents
The following code should be pasted into the .conf file:
server {
listen 80;
listen [::]:80;
server_name nesula.ifactory.co;
root /var/www/nesula.ifactory.co;
index index.html;
location / {
proxy_pass http://localhost:3000; #whatever port your app runs on
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;
}
}
Save your .conf file in Nano or whatever editor you are using.
Symlink Sites Enabled
To enable a website in Nginx a symlink must be created between the .conf in the sites-enabled and sites-available folders:
sudo ln -s /etc/nginx/sites-available/nesula.ifactory.co.conf /etc/nginx/sites-enabled/nesula.ifactory.co.conf
Test Nginx config
To establish if the new site .conf is correct run:
$ nginx -t
Restart Nginx
Restart nginx to ensure the site .conf is available to the world:
$ sudo systemctl restart nginx
Last updated
Was this helpful?