Why Nginx?

Nginx sits between the public Internet and Odoo, providing several critical functions in a production deployment.

🔒 SSL termination
Handles HTTPS, allowing Odoo to remain a plain HTTP server internally
🔗 WebSocket proxy
Proxies long-lived WebSocket connections required by Odoo's live chat and bus
📦 Static caching
Serves and caches static assets efficiently, reducing load on Odoo
🛡️ Port hiding
Keeps port 8069 private; all traffic enters through ports 80 and 443

Install Nginx from the Ubuntu repositories.

bash
sudo apt install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx

Nginx Configuration

Create a new virtual host configuration file for Odoo.

bash
sudo nano /etc/nginx/sites-available/odoo

Paste the following complete configuration. Replace odoo.example.com with your actual domain.

nginx
upstream odoo {
    server 127.0.0.1:8069;
}

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

server {
    listen 80;
    server_name odoo.example.com www.odoo.example.com;

    # Increase max upload size for attachments and backups
    client_max_body_size 100M;

    # Proxy timeouts for long-running operations
    proxy_read_timeout    720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout    720s;
    proxy_buffering off;

    # Required headers so Odoo knows the real client details
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port  $server_port;

    # WebSocket support (required for Odoo bus and live chat)
    location /websocket {
        proxy_pass http://odoo;
        proxy_http_version 1.1;
        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }

    # Static files with caching
    location /web/static/ {
        proxy_pass http://odoo;
        expires 10d;
        proxy_cache_valid 200 90m;
    }

    # All other requests
    location / {
        proxy_pass http://odoo;
    }
}

Enable the site, test the configuration, and reload Nginx.

bash
sudo ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/odoo

# Disable the default site
sudo rm -f /etc/nginx/sites-enabled/default

sudo nginx -t

sudo systemctl reload nginx
proxy_buffering off

Disabling proxy buffering is important for Odoo. It ensures that responses are streamed to the client directly without waiting for the complete response to be buffered, which is critical for Odoo's real-time operations.

Verification

bash
sudo nginx -t
sudo systemctl status nginx --no-pager
curl -I http://127.0.0.1
  • nginx -t reports syntax is ok and test is successful
  • Nginx is active (running)
  • curl to port 80 returns an Odoo response or redirect
  • Default Nginx welcome page is disabled

Common Issues

ProblemCauseResolution
Default Nginx welcome pageDefault site still enabledRemove /etc/nginx/sites-enabled/default and reload Nginx
502 Bad GatewayOdoo not running or wrong portVerify systemctl status odoo and that Odoo is listening on port 8069
WebSocket errors in OdooMissing Upgrade/Connection headersCheck the /websocket location block in the Nginx config
413 Request Entity Too Largeclient_max_body_size too smallIncrease client_max_body_size in the Nginx config
Slow static assetsCaching not configuredVerify the /web/static/ location block with expires
Never expose port 8069 publicly

Odoo's built-in server is not designed to be exposed directly to the Internet. Always use Nginx as the entry point. Verify with sudo ss -tlnp | grep 8069 — the address should be 127.0.0.1:8069, not 0.0.0.0:8069.

Back to top