How can nginx be added to UFW. nginx is not appearing in the UFW lst?
When running the command:
ufw app list
Nginx does not appear in it. How can nginx be added to UFW?
Any help would be greatly appreciated?
How can nginx be added to UFW. nginx is not appearing in the UFW lst?
When running the command:
ufw app list
Nginx does not appear in it. How can nginx be added to UFW?
Any help would be greatly appreciated?
its easy to add your own app:
create a file:
/etc/ufw/applications.d/nginx
with the following content:
[Nginx]
title=Nginx Web Server (HTTP + HTTPS)
description=Small, but very powerful and efficient web server
ports=80,443/tcp
tell ufw about the new app:
ufw app update Nginx
allow Nginx:
ufw allow Nginx
After a bit of tinkering i realized that it's possible to separate the configuration between HTTP and HTTPS. I took the idea from the default configuration of NGINX from the Ubuntu 20.04 repo.
Create ufw nginx conf file
sudo vim /etc/ufw/applications.d/nginx
Add ufw nginx configurations
[Nginx HTTP]
title=Web Server (Nginx, HTTP)
description=Small, but very powerful and efficient web server
ports=80/tcp
[Nginx HTTPS]
title=Web Server (Nginx, HTTPS)
description=Small, but very powerful and efficient web server
ports=443/tcp
[Nginx Full]
title=Web Server (Nginx, HTTP + HTTPS)
description=Small, but very powerful and efficient web server
ports=80,443/tcp
Back to the CLI
ufw app update nginx
ufw allow 'Nginx HTTP' # Allow HTTP
ufw allow 'Nginx HTTPS' # Allow HTTP
ufw allow 'Nginx Full' # Allow HTTP, HTTPS
Output
# > Rule added
# > Rule added (v6)