Introduction
When deploying Odoo in a production environment, exposing Odoo directly on port 8069 is not recommended. Instead, Nginx should be placed in front of Odoo as a reverse proxy.
Nginx improves security, performance, scalability, and allows you to use professional domain names and SSL certificates.
In this guide, we will explain every step of an Odoo Nginx deployment, including the purpose of each configuration parameter.
Why Use Nginx with Odoo?
Without Nginx:
http://YOUR_SERVER_IP:8069
Problems:
- No HTTPS security
- Exposes Odoo port publicly
- Difficult domain management
- Poor scalability
- No load balancing
With Nginx:
Benefits:
- SSL/HTTPS support
- Reverse proxy protection
- Domain management
- Better performance
- Websocket support
- Security enhancements
Architecture Overview
Client Browser
↓
Domain (erp.company.com)
↓
Nginx (Port 80/443)
↓
Odoo Application (Port 8069)
↓
PostgreSQL Database
Users never communicate directly with Odoo.
All traffic passes through Nginx first.
Step 1: Install Nginx
Update packages:
sudo apt update
Purpose:
Refreshes the package repository list.
Install Nginx:
sudo apt install nginx -y
Purpose:
Installs Nginx web server.
Check version:
nginx -v
Purpose:
Verifies installation.
Check status:
sudo systemctl status nginx
Purpose:
Confirms Nginx service is running.
Step 2: Configure Odoo
Open Odoo configuration:
sudo nano /etc/odoo.conf
Example:
[options] db_host = False db_port = False db_user = odoo db_password = False proxy_mode = True xmlrpc_port = 8069 longpolling_port = 8072 workers = 4 limit_time_real = 1200 limit_time_cpu = 1200
Parameter Explanation
proxy_mode = True
Purpose:
Allows Odoo to trust headers coming from Nginx.
Without this:
- Wrong redirects
- SSL issues
- Incorrect client IP
xmlrpc_port = 8069
Purpose:
Main Odoo application port.
Example:
longpolling_port = 8072
Purpose:
Used for:
- Discuss module
- Live chat
- Notifications
- Bus services
- Real-time updates
workers = 4
Purpose:
Enable multiprocessing.
Recommended:
(CPU Cores × 2) + 1
Example:
2 CPU → 5 workers
Restart Odoo
sudo systemctl restart odoo
Step 3: Create Nginx Configuration
Create file:
sudo nano /etc/nginx/sites-available/odoo.conf
Complete Nginx Configuration
server {
listen 80;
server_name erp.company.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
client_max_body_size 200M;
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;
location / {
proxy_pass http://127.0.0.1:8069;
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-Proto $scheme;
}
location /websocket {
proxy_pass http://127.0.0.1:8072;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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;
}
}
Configuration Explained
listen 80
Purpose:
Accept HTTP requests.
server_name erp.company.com
Purpose:
Maps the domain to this configuration.
proxy_pass
Purpose:
Forwards requests to Odoo.
proxy_pass http://127.0.0.1:8069;
Browser never sees port 8069.
proxy_read_timeout
Purpose:
Large reports or imports may take several minutes.
Default timeout may terminate requests.
client_max_body_size 200M
Purpose:
Allows:
- Large attachments
- Product imports
- Database backups
- Excel uploads
access_log
Purpose:
Stores successful requests.
Example:
tail -f /var/log/nginx/odoo_access.log
error_log
Purpose:
Stores errors.
Example:
tail -f /var/log/nginx/odoo_error.log
Step 4: Enable Configuration
Enable site:
sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/
Purpose:
Creates active configuration link.
Remove default site:
sudo rm -f /etc/nginx/sites-enabled/default
Purpose:
Avoid conflicts.
Step 5: Validate Nginx
sudo nginx -t
Purpose:
Check syntax before restart.
Expected:
syntax is ok test is successful
Step 6: Restart Nginx
sudo systemctl restart nginx
Verify:
sudo systemctl status nginx
Step 7: Configure Firewall
Ubuntu UFW:
sudo ufw allow 80 sudo ufw allow 443 sudo ufw reload
Purpose:
Allow:
- HTTP
- HTTPS
Useful Commands
Reload Nginx:
sudo systemctl reload nginx
Restart Nginx:
sudo systemctl restart nginx
Stop Nginx:
sudo systemctl stop nginx
View Logs:
tail -f /var/log/nginx/error.log
Check Open Ports:
sudo netstat -tulpn
Common Troubleshooting
502 Bad Gateway
Check:
sudo systemctl status odoo
Verify Odoo running on:
127.0.0.1:8069
Websocket Not Working
Verify:
longpolling_port = 8072
and Nginx websocket section exists.
Domain Not Opening
Check DNS:
nslookup erp.company.com
Verify it points to server IP.
Conclusion
Nginx is an essential component of every production Odoo deployment. It provides security, SSL support, domain management, performance optimization, websocket handling, and a professional architecture suitable for businesses of all sizes.
A properly configured Nginx server ensures your Odoo ERP remains secure, scalable, and production-ready.
AxenorSuite Consultancy Services LLP
📞 +91 8460110120
