Firewall is essential to restrict allow of required Network traffic and disallow other network traffic. While setting up Ubuntu Operating system, we define firewall for openssh. (If you have no idea about this, check chapter 3 of this cloud hosting tutorial series. All the chapter list are present below this article.)
After successfull installation of Nginx Server, we must have to set firewall for Netflix.
Firewall Configuration for Nginx Server
Following command will set firewall rule for Nginx Server.
test@tester:~$ sudo ufw allow ‘Nginx HTTP’
After successful execution of above command, its time to enable ufw. Use following command for this.
test@tester:~$ sudo ufw enable
For confirmation, lets check the firewall status using following command
test@tester:~$ sudo ufw status
The above command is going to print something similar to below. It clearly tells the firewall is set for Nginx and OpeenSSH as well.
Status: active
To Action From
— —— —-
OpenSSH ALLOW Anywhere
Nginx HTTP ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx HTTP (v6) ALLOW Anywhere (v6)
Conclusion
So this is the way we set UFW firewall for Nginx Server in Ubuntu 20.04 operating system in cloud hosting.