Skip to Content

Odoo Load Balancer (Nginx): Step-by-Step Configuration

November 8, 2026 by

As more and more users rely on Odoo, a single instance is no longer enough. Slowdowns appear, and a server failure means downtime for the entire company. The solution is to spread the traffic across several application servers. In this article, we show how to configure Odoo with a load balancer to ensure performance, scalability and high availability. The configuration described applies to current Odoo versions (16 and later, including 18 and 19).

Want to see how Odoo works in practice before you start planning your architecture? Try the system for free.

Try Odoo for free

Why use a load balancer with Odoo?

A load balancer receives traffic from users and routes it to one of several Odoo servers. This gives you:

  • Performance – the load is spread across multiple machines.
  • High availability – when one node goes down, the others keep serving users.
  • Less downtime during maintenance – you can take nodes offline one at a time, e.g. for a restart or when deploying changes that do not require a database migration.
  • Security – Odoo servers can run in a private network, with only the load balancer exposed publicly and protected by SSL/TLS encryption.

Before you start scaling horizontally, make sure you have made full use of a single machine. Our articles can help: how to configure Odoo with multiple workers and proven methods for optimizing Odoo performance.

Odoo architecture with a load balancer

A typical deployment consists of several layers:

  1. Load balancer / reverse proxy – e.g. Nginx, HAProxy or a cloud service.
  2. At least two Odoo application servers with the identical Odoo version, modules and configuration.
  3. A shared PostgreSQL database – all nodes connect to the same database (ideally with replication and a failover mechanism).
  4. Shared filestore and sessions – attachments and session data must be available to every node.

Prerequisites

  • Two or more servers with the same Odoo version and the same custom module code.
  • Access to a single PostgreSQL database (writes always go to one primary instance).
  • A shared data directory (e.g. NFS or another network file system) for the filestore and sessions.
  • A server with Nginx or HAProxy acting as the load balancer.

Step 1: Configuring the odoo.conf file

On each Odoo node, set the parameters suited to running behind a reverse proxy in the configuration file:

[options]
proxy_mode = True
workers = 4
max_cron_threads = 1
gevent_port = 8072
data_dir = /mnt/odoo-shared
db_host = 10.0.0.5
db_port = 5432
db_user = odoo
db_password = ********
db_maxconn = 64
admin_passwd = ********
list_db = False
dbfilter = ^database_name$

Key parameters

  • proxy_mode = True – Odoo trusts the X-Forwarded-* headers passed by the load balancer, so it correctly recognizes the client address, host and HTTPS protocol. Enable it only when Odoo is accessible exclusively through a trusted proxy.
  • workers – enables multiprocessing mode. Choose a value based on the number of CPU cores and the RAM of the given node. Running with workers is also a prerequisite for websockets to work.
  • max_cron_threads – the number of scheduled action threads. Cron jobs are protected by database locks, so they can run on multiple nodes at the same time, but they are often limited to selected nodes (set to 0 on the others) to make it easier to control the load.
  • gevent_port – the port of the process that handles websocket connections, used by chat and notifications, among other things (in older versions it was called longpolling_port). The default is 8072.
  • data_dir – a shared directory with the filestore and sessions. Without it, users may get logged out and attachments may be unavailable on some nodes.
  • db_maxconn – the limit of database connections per process. Remember that the total number of connections (nodes × processes × db_maxconn) must fit within the max_connections parameter of the PostgreSQL server.
  • admin_passwd – a strong master password that protects database operations.
  • list_db = False and dbfilter – protect against exposing the list of databases in a production environment.

The websocket (gevent) process connects to the database directly and uses the LISTEN/NOTIFY mechanism in PostgreSQL, so notifications reach users regardless of the node. If you use PgBouncer, connections for Odoo must bypass transaction pooling mode, which does not support LISTEN/NOTIFY.

By default, Odoo sessions are stored as files in the data_dir directory. Sharing them over NFS works, but it can be slow under heavy traffic. With a larger number of users, you can move sessions to Redis, although this requires an additional module (Odoo does not support it natively). We describe the details in our guide on how to configure Redis for Odoo.

Configuring shared resources and sessions can be demanding. If you would rather leave it to specialists, contact us.

Contact us

Step 2: Configuring Nginx as a load balancer

Below is an example Nginx configuration that distributes HTTP and websocket traffic between two Odoo nodes. Place the upstream and map blocks in the http context (e.g. in a file in the conf.d directory):

upstream odoo_backend {
    ip_hash;
    server 10.0.0.11:8069 max_fails=3 fail_timeout=30s;
    server 10.0.0.12:8069 max_fails=3 fail_timeout=30s;
}

upstream odoo_websocket {
    ip_hash;
    server 10.0.0.11:8072 max_fails=3 fail_timeout=30s;
    server 10.0.0.12:8072 max_fails=3 fail_timeout=30s;
}

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

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

server {
    listen 443 ssl;
    server_name erp.twojadomena.pl;

    ssl_certificate     /etc/ssl/certs/erp.crt;
    ssl_certificate_key /etc/ssl/private/erp.key;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;

    location /websocket {
        proxy_pass http://odoo_websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        # headers from the server level are not inherited
        # when a location defines its own proxy_set_header
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location / {
        proxy_pass http://odoo_backend;
        proxy_redirect off;
    }
}

Note the location /websocket block: in Nginx, proxy_set_header directives from the server level are not inherited if a given location defines its own. That is why the Host and X-Forwarded-* headers must be repeated in it. Otherwise, Odoo may reject websocket connections or generate incorrect URLs.

Why ip_hash?

The ip_hash directive provides so-called sticky sessions: a user lands on the same node every time. With a shared session directory or Redis, this is not strictly necessary, but it reduces data inconsistency issues, lowers the load on shared storage and makes troubleshooting easier. In environments where many users connect from a single IP address (e.g. an office behind NAT), traffic may be distributed unevenly. In that case, consider other session persistence methods, for example cookie-based ones in HAProxy.

Step 3: Health checks and failure handling

The load balancer should know which node is working correctly. In Nginx Open Source, only passive checks are available: the max_fails and fail_timeout parameters in the server definition. Active health checks are offered by HAProxy (and by the paid Nginx Plus), which can periodically call the /web/health endpoint. A node that does not respond is automatically removed from the pool, and traffic goes to the remaining servers.

Keep in mind that the load balancer itself is also a single point of failure. In a mission-critical environment, it is worth using two load balancers with a mechanism such as Keepalived and a virtual IP address. Similarly, the PostgreSQL database requires replication and automatic failover, e.g. using Patroni.

Step 4: Testing the configuration

  1. Log in to Odoo through the load balancer address and check that the session stays active after refreshing the page.
  2. Upload an attachment and make sure it is available regardless of which node handles the request.
  3. Shut down one of the nodes and check that the system still works.
  4. Verify that notifications and chat (websocket) work, e.g. in your browser's developer tools, check that the /websocket connection has status 101.
  5. Run a load test to check how traffic is actually distributed.

Logs from each node will come in handy when analyzing problems. See how to configure logging to a file in Odoo.

Most common problems

  • Users getting logged out – sessions are not shared between nodes or sticky sessions are missing.
  • No notifications or chat – incorrectly configured routing to port 8072, missing Upgrade headers for websocket, no workers, or the Host and X-Forwarded-* headers omitted in the /websocket block.
  • Attachments not working – the filestore is not shared.
  • Incorrect URLs or http instead of https – missing proxy_mode = True or X-Forwarded-* headers.
  • The "too many clients" error in PostgreSQL – the sum of connections from all nodes exceeds max_connections.
  • Connection error – the node is not listening on the correct port or a firewall is blocking it. This article will help: how to fix the Connection Refused error in Odoo.

Best practices

  • Keep identical versions of Odoo and modules on all nodes. Changes without a database schema migration can be deployed one node at a time (rolling restart), but run module updates (-u) from a single node, with the other nodes stopped or detached from the load balancer.
  • Protect PostgreSQL with replication and regular backups.
  • Monitor CPU load, memory, the number of database connections and response times.
  • Terminate SSL/TLS connections at the load balancer and restrict access to ports 8069 and 8072 to the internal network only.
  • Remember that application nodes will not remove the bottleneck if a slow database is the problem – make sure you optimize it.

Planning to scale Odoo and want to get to know the system's capabilities first? Try Odoo for free.

Try Odoo for free

FAQ – frequently asked questions

Do I need multiple servers for Odoo with a load balancer?

To achieve high availability, yes – you need at least two application nodes. However, a load balancer can also run in front of a single instance, acting as a reverse proxy that handles SSL and increases security.

Do Odoo sessions have to be shared?

Yes, in practice always, if business continuity matters to you. Without sticky sessions, a user lands on different nodes, so the session must be available on each of them. But even with sticky sessions, a node failure moves the user to another server, which will log them out if sessions are not shared. Sessions can be shared through a common data directory or Redis (with an additional module). The safest approach is to combine shared sessions with sticky sessions.

How do cron jobs work with multiple Odoo nodes?

Each node can run scheduled actions, and database locks prevent the same job from being executed by two processes at once. If you want to control where jobs run, set max_cron_threads = 0 on selected nodes.

Which load balancer should I choose: Nginx or HAProxy?

Both solutions work well with Odoo. Nginx is simpler and is often already used as a reverse proxy. HAProxy offers active health checks, more advanced session persistence methods (e.g. based on cookies) and detailed statistics. The choice depends on the scale of the deployment and the team's experience.

Summary

Configuring Odoo with a load balancer requires a well-thought-out architecture: a correct odoo.conf file, a shared filestore and sessions, proper websocket routing with a complete set of headers, control over the number of database connections, and monitoring. The result is a stable, scalable system that can withstand growth in the number of users and the failure of individual servers.

Need help implementing high availability for Odoo? The KK Innovations team will design, configure and optimize an environment tailored to your company. Get in touch with us today.

Contact us