How to Configure Nginx Reverse Proxy for an Odoo Instance
Running Odoo behind Nginx as a reverse proxy is the recommended production setup. Nginx improves performance, handles long polling correctly, allows large file uploads, and prepares your server for SSL.
This guide shows how to configure Nginx for an Odoo instance...
Prerequisites
Before configuring Nginx as a reverse proxy for Odoo, ensure the following requirements are met:
1. Domain Name
You must have a registered domain or subdomain (for example: odoo.example.com).
2. Point Domain to Server IP
Update your domain’s DNS records to point to your server’s public IP address.
Example DNS Record:
| Type | Host | Value (Server IP) |
|---|---|---|
| A | odoo | 123.456.78.90 |
Or for wildcard subdomains:
| Type | Host | Value |
|---|---|---|
| A | * | 123.456.78.90 |
DNS propagation may take a few minutes to several hours.
3. Public Server IP
Ensure your server has:
A public IPv4 address
Ports 80 (HTTP) and 443 (HTTPS, optional) open
You can check your server IP using:
curl ifconfig.me
4. Running Odoo Instance
Odoo must already be installed and running
Example:
Odoo HTTP port: 8069
Longpolling port: 8072
Verify Odoo is running:
sudo systemctl status odoo
Step 1: Install Nginx Web Server
Update packages and install Nginx:
sudo apt update
sudo apt install nginx -y
sudo ufw allow 'Nginx HTTP' sudo ufw reload
Verify installation:
nginx -v
Step 2: Create Nginx Configuration for Odoo
Create a new configuration file:
sudo nano /etc/nginx/sites-available/odoo19.conf
Paste the following configuration:
# Odoo backend
upstream odoo {
server 127.0.0.1:8069;
}
# Odoo longpolling
upstream odoochat {
server 127.0.0.1:8072;
}
server {
listen 80;
server_name your_domain_or_ip;# change your_domain_or_ip to your # real one
# Timeouts
proxy_read_timeout 7200s;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
# Odoo proxy headers
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-Real-IP $remote_addr;
# Logs
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
# Main Odoo location
location / {
proxy_redirect off;
proxy_pass http://odoo;
}
# Long polling (chat, bus)
location /longpolling {
proxy_pass http://odoochat;
}
# Static files caching
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 10d;
proxy_pass http://odoo;
}
# Gzip compression
gzip on;
gzip_types text/css text/plain text/xml application/xml application/json application/javascript;
# Upload limits
client_body_in_file_only clean;
client_body_buffer_size 128K;
client_max_body_size 500M;
sendfile on;
keepalive_timeout 7200;
}
🔹 Replace your_domain_or_ip with:
example.com
odoo.example.com
or your server IP
Step 3: Enable Nginx Site
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/
(Optional) Remove default site:
sudo rm /etc/nginx/sites-enabled/default
Step 4: Test and Restart Nginx
Check configuration:
sudo nginx -t
Output Example
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart Nginx Service:
sudo service nginx restart
Output Example
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: active (running)