Nginx

During this course, I have learned how to set up a nginx web server on Ubuntu 20.4. The Digital Ocean documentation gives all detail steps require to set up nginx as a web server.

Nginx management

It is possible to verify that nginx is still up and running using the systemctl command

systemctl status nginx

To apply configuration update while nginx is running without running down all connections

systemctl reload nginx

Step 1: Install Nginx

Nginx can be installed using the apt package management tool.

sudo apt update
sudo apt install nginx

Step 2: Firewall configuration

To allow the traffic on port 80 (HTTP) and 443 (HTTPS).

Nginx has three profiles.

Nginx Full - Allow traffic on port 80 and 443.

Nginx HTTP - Allow traffic only on port 80 (HTTP)

Nginx HTTPS - Allow only traffic on port 443 (HTTPS)

sudo ufw allow <'NGINX_PROFIL'>

Disable server type and version

On our webserver, it is always recommended to remove the Server response header disclosing the type and version of our web server. Attackers could use this information to browse their attack surface.

Add this line to the configuration file of our website.

#!!! This will only remove the version of nginx not the Server header
server_tokens off;

Last updated