Nginx Installation and Firewall Configuration

AiroServer's Blog

In this post, we’ll explain the installation for the latest version of Nginx and its firewall configuration.

Nginx is one of Linux web servers which has lots of pros and cons. One thing about Nginx is that it doesn’t have a panel on control panels like other web servers. So this makes things a bit harder but still manageable. In our last post, we explained how you can install SSL with having Nginx as your web server.

Nginx Web Server

Nginx Installation

Connect to your server using an SSH connection. Now use the command below to download and install the latest version of Nginx on your server.

sudo apt update && sudo apt install nginx
sudo apt install -y nginx

After the installation, you can check the installed version using this command:

nginx -v

Then you need to check the web server’s status as we want it to be up and running:

sudo service nginx status

The Nginx installation is complete and now you need to configure the firewall.

Firewall Configurations

After the installation, we recommend you to enable ufw so you’ll be able to add rules on Nginx. (Before doing that, check your SSh access so you won’t get blocked.)

sudo ufw allow OpenSSH

Now let’s add rules on Nginx:

sudo ufw allow 'Nginx HTTP'

You should see this:

Rule added
Rule added (v6)

Enabling ufw in Firewall:

sudo ufw enable

Now let’s check the Firewall’s status:

sudo ufw status

You should see this:

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
Nginx HTTP                 ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
Nginx HTTP (v6)            ALLOW       Anywhere (v6)

Nginx installation is done and it’s up and running now!

In our next post, we are going to show you how you can handle more than one domain with Nginx web server.

Hope you eno=joyed this post if you did, you can visit our blog for more!

Find More Articles...

Whats New?

en_USEN