Skip to Content

How to Configure a Firewall for Odoo: Step-by-Step Guide

November 9, 2026 by

An Odoo server stores your company's financial data, contacts, inventory and documents. Exposed to the internet without protection, it quickly becomes a target for automated scanners and brute-force attacks. A well-configured firewall is the first and one of the most effective lines of defense. In this guide, we will show you step by step how to configure a firewall for Odoo (including the latest version 19) on a Linux server, so that only the ports you truly need are open.

If you are just starting out with Odoo, first see how the system works in practice on your own free trial instance.

Try Odoo for free

Why is a firewall for Odoo so important?

By default, Odoo listens on port 8069 on all interfaces and has no built-in firewall. The PostgreSQL database, in turn, runs on port 5432. If both ports are reachable from the internet, an attacker can try to crack passwords, exploit known vulnerabilities or overload the server with requests. A firewall allows you to:

  • restrict access to services to trusted IP addresses only,
  • hide PostgreSQL from the outside world,
  • close direct access to Odoo, so that all traffic goes through a reverse proxy that enforces an encrypted HTTPS connection,
  • reduce the impact of port scanning and simple network attacks (protection against advanced DDoS requires a provider-level service, such as a CDN or WAF).

Which ports does Odoo use?

Before you start configuring rules, you need to know which ports are in use:

  • 22 – SSH, remote server management,
  • 80 – HTTP (redirect to HTTPS and Let's Encrypt certificate validation),
  • 443 – HTTPS, the main access point for users,
  • 8069 – the default Odoo HTTP port,
  • 8072 – the default port of the gevent process (the gevent_port parameter), which handles real-time WebSocket connections (chat, notifications, Discuss channels). This process runs in multi-worker mode, that is, when workers is greater than zero,
  • 5432 – PostgreSQL.

The rule is simple: only ports 80, 443 and optionally 22 (ideally restricted to selected IP addresses) should be open to the outside. Ports 8069, 8072 and 5432 should be accessible locally only.

Step 1: Configure UFW on Ubuntu and Debian

UFW (Uncomplicated Firewall) is the simplest tool for managing rules on Ubuntu and Debian systems. Start by setting the default policy:

sudo ufw default deny incoming
sudo ufw default allow outgoing

Then allow the necessary traffic:

sudo ufw allow from 203.0.113.10 to any port 22 proto tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

Replace 203.0.113.10 with your own static office or VPN IP address. Note: before enabling UFW, make sure the SSH rule is correct, otherwise you will lose access to the server.

If you run Odoo in Docker, keep in mind that Docker publishes ports bypassing UFW rules. Instead of the 8069:8069 mapping, use the 127.0.0.1:8069:8069 entry in your docker-compose file so that the port is accessible locally only (for the reverse proxy).

Step 2: Configure firewalld on RHEL and derivatives

On Red Hat family distributions (RHEL, AlmaLinux, Rocky Linux, CentOS Stream), the default tool is firewalld. If you are just installing the system, check out our guide How to Install Odoo 19 on CentOS/RHEL. Then open the HTTP and HTTPS ports:

sudo systemctl enable --now firewalld
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

If you previously opened port 8069 for testing, remove it:

sudo firewall-cmd --permanent --remove-port=8069/tcp
sudo firewall-cmd --reload

By default, firewalld allows SSH from any address. To restrict it to a trusted IP, add a rich rule and remove the general ssh service (first make sure the new rule works):

sudo firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=203.0.113.10 service name=ssh accept'
sudo firewall-cmd --permanent --remove-service=ssh
sudo firewall-cmd --reload

Step 3: Hide Odoo behind a reverse proxy

Instead of exposing Odoo directly, use Nginx as a reverse proxy. Nginx accepts traffic on ports 80 and 443 and then forwards it locally to Odoo. This lets you close port 8069 to the outside world. In the odoo.conf file, set Odoo to listen only on the local interface:

http_interface = 127.0.0.1
proxy_mode = True
workers = 4
gevent_port = 8072

The proxy_mode option is required for Odoo to correctly recognize client IP addresses and the HTTPS protocol forwarded by Nginx. Adjust the number of workers to your server's resources. A value greater than zero starts the gevent process that handles WebSocket on port 8072.

In the Nginx configuration, route regular traffic to port 8069 and the /websocket path to port 8072 (the snippet omits the SSL certificate directives):

upstream odoo { server 127.0.0.1:8069; }
upstream odoochat { server 127.0.0.1:8072; }

map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}

server {
  listen 80;
  server_name erp.example.com;
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl;
  server_name erp.example.com;

  location /websocket {
    proxy_pass http://odoochat;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
  }

  location / {
    proxy_pass http://odoo;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
  }
}

If you are planning a more extensive infrastructure with multiple application servers, see the article Odoo Load Balancer (Nginx): Step-by-Step Configuration.

A firewall is just one element of a secure deployment. If you want to see how Odoo works in a fully managed environment, try it on your own instance.

Try Odoo for free

Step 4: Secure PostgreSQL

The database should not be visible from the internet. When PostgreSQL runs on the same server as Odoo, check the postgresql.conf file and make sure the server listens only locally (this is the default value):

listen_addresses = 'localhost'

Remote access for selected addresses only

If the database runs on a separate server, restrict access to the application server's address. First, in postgresql.conf, set the database server to listen on its private address (e.g. 10.0.0.10) rather than on all interfaces:

listen_addresses = 'localhost,10.0.0.10'

Then, in UFW, allow connections only from the application server:

sudo ufw allow from 10.0.0.5 to any port 5432 proto tcp

Additionally, configure the pg_hba.conf file so that it accepts connections only from a specific address and for a specific database user, with scram-sha-256 authentication:

host  all  odoo  10.0.0.5/32  scram-sha-256

On the Odoo side, point to the database server in the odoo.conf file (the db_host, db_port, db_user and db_password parameters). Ideally, communication should take place over a private network or through a VPN.

Step 5: Add Fail2ban against brute-force attacks

A firewall blocks ports, but it does not protect against password-cracking attempts on open services. Fail2ban analyzes logs and automatically blocks IP addresses that have repeatedly failed to log in. After installation, enable the SSH jail, and for Odoo create your own filter based on failed login messages (Login failed) in the application logs. An example /etc/fail2ban/filter.d/odoo.conf file may look like this:

[Definition]
failregex = ^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d+ \d+ INFO \S+ odoo\.addons\.base\.models\.res_users: Login failed for db:\S+ login:\S+ from <HOST>
ignoreregex =

Test the expression against your own logs using the fail2ban-regex command, because the format of log entries depends on your logging configuration. With proxy_mode enabled, the logs show the real client IP address rather than the Nginx address. This also requires logging to a file to be enabled, which we described in the article How to Configure File Logging in Odoo.

Configuring filters, network zones and rules for production environments can be complex, and a mistake can cut off users or lock administrators out. If you prefer to leave this to specialists, contact us.

Contact us

Also secure the Database Manager

A firewall is not everything. The Odoo database management page should be disabled in production (the list_db = False option), and access to the right database should be restricted with the dbfilter parameter. The master password (admin_passwd) must be strong and unique. You can find the details in the article Odoo Database Manager: How It Works and How to Secure It.

Testing and troubleshooting

Once the configuration is complete, check that the rules work as intended:

  • from an external computer, try to connect to ports 8069, 8072 and 5432 (e.g. with the command nmap -p 22,80,443,8069,8072,5432 server-address). They should be unreachable, with only ports 80 and 443 open (and 22 from allowed addresses),
  • check that the site works over HTTPS on port 443 and that HTTP redirects to HTTPS,
  • use the sudo ss -tlnp command to see which services are listening and on which interfaces (Odoo should be listening on 127.0.0.1),
  • check that chat and real-time notifications work, which confirms that /websocket is correctly forwarded to port 8072,
  • review the firewall and Nginx logs for blocked connections.

If a connection refused error appears after the changes, the most common cause is an overly restrictive rule or an incorrect listening address. This guide will help you Odoo Connection Refused Error: Causes and Step-by-Step Fixes.

Best practices

  • Apply the principle of least privilege: block everything by default and open only what is necessary.
  • Restrict SSH to selected IP addresses or VPN access, and use keys instead of passwords.
  • Regularly update the operating system, PostgreSQL and Odoo.
  • Document your rule configuration so you can easily restore it after a failure.
  • Test changes in a staging environment before deploying to production.
  • Regularly back up the database and files (filestore) and verify that they can be restored.

FAQ – frequently asked questions

Do I need to open port 8069 in the firewall?

No. If you use Nginx as a reverse proxy, port 8069 should be accessible locally only. Only ports 80 and 443 are open to the outside.

Does port 8072 also need to be secured?

Yes. Port 8072 handles real-time WebSocket connections and should be accessible only to the reverse proxy, which routes traffic to it on the /websocket path. Do not open it directly to the internet.

Which firewall should I choose: UFW, firewalld or iptables?

The choice depends on your distribution. UFW is the most convenient on Ubuntu and Debian, and firewalld on RHEL and derivatives. They all use the same Linux kernel mechanism (netfilter, via iptables or nftables), so the level of protection is comparable as long as the rules are configured correctly.

Is a firewall enough to secure Odoo?

No. A firewall restricts access to services, but it does not replace updates, strong passwords, disabling the Database Manager, backups and monitoring. Treat it as one layer of protection.

Summary

A well-designed firewall for Odoo combines closed ports, a reverse proxy, restricted access to PostgreSQL and additional mechanisms such as Fail2ban. This way, your instance is much better protected against attacks, and your company data stays safe.

Need help deploying a secure Odoo infrastructure? The KK Innovations team will configure your server, firewall, Nginx and monitoring for you. Get in touch today.

Contact us