To allow PostgreSQL and Nginx through the firewall by specifying the ports they use, you can use the ufw
(Uncomplicated Firewall) utility on Ubuntu. Here's how you can do it:
Allow PostgreSQL (Postgres) Port:
By default, PostgreSQL uses port 5432. To allow PostgreSQL through the firewall, you can use the following command:
sudo ufw allow 5432/tcp
This command allows incoming TCP traffic on port 5432, which is the default PostgreSQL port.
Allow Nginx Port:
Nginx uses port 80 (HTTP) and/or port 443 (HTTPS) to serve web traffic. You can allow these ports using the following commands:
For HTTP (port 80):
sudo ufw allow 80/tcp
For HTTPS (port 443):
sudo ufw allow 443/tcp
These commands allow incoming TCP traffic on ports 80 and 443, which are the default ports for HTTP and HTTPS traffic served by Nginx.
After running these commands, make sure to check the status of the firewall rules to ensure that they are correctly configured:
sudo ufw status
You should see the rules you've added, and they should be marked as "ALLOW." If everything looks correct, you can reload the firewall to apply the changes:
sudo ufw reload
Your PostgreSQL and Nginx services should now be accessible through their respective ports, and they are allowed through the firewall.
Top comments (0)