Step5: Setup Firewall for your Remote Server - SwagatoMondal/Online-Shopping GitHub Wiki

You can setup a simple firewall for your Web server (This document will cover UFW).

Install UFW

In order to install UFW in your remote machine, use the following command -

<username>@<hostname>:~$ sudo apt-get install ufw

Adding simple rules

<username>@<hostname>:~$ sudo ufw default allow outgoing
<username>@<hostname>:~$ sudo ufw default deny incoming

Now don't forget to allow ssh or http login to your remote, otherwise you'll be locked out.

<username>@<hostname>:~$ sudo ufw allow ssh

Allow a particular port number to run (Optional), for example 8000 -

<username>@<hostname>:~$ sudo ufw allow 8000

Enable firewall

Now you're set with the firewall rule(s), let's enable it by running the following command -

<username>@<hostname>:~$ sudo ufw enable

NOTE : You'll prompted to proceed, enter y to continue.

Verify status

You can verify the firewall status by running the following command -

<username>@<hostname>:~$ sudo ufw status
Status: active

// Other info
⚠️ **GitHub.com Fallback** ⚠️