How to Configure Nginx as a Reverse Proxy for Odoo 18
Learn how to configure Nginx, enable HTTPS, and securely access your Odoo ERP through a custom domain.
Nginx is a high-performance web server commonly used as a reverse proxy for Odoo ERP. By configuring Nginx, businesses can access Odoo through a custom domain, enable HTTPS encryption, and manage incoming web traffic more efficiently. This tutorial explains how to set up Nginx for Odoo 18 running on an Ubuntu server.
Step 1 — Install Nginx
Connect to your Ubuntu server using SSH and run:
sudo apt update sudo apt install nginx -y
Enable and start Nginx:
sudo systemctl enable nginx sudo systemctl start nginx
Verify the service:
sudo systemctl status nginx
Make sure your domain points to the server's public IP address.
Step 2 — Enable Proxy Mode in Odoo
Open your Odoo configuration file:
sudo nano /etc/odoo.conf
Add or update the following settings:
[options] proxy_mode = True http_interface = 127.0.0.1 http_port = 8069
For a production deployment using multiple workers, also configure:
workers = 2 gevent_port = 8072
Adjust the worker count based on server resources and workload. The dedicated gevent port is used for WebSocket connections in multi-worker mode.
Restart Odoo:
sudo systemctl restart odoo
Note: The configuration path and service name may differ depending on your installation. Enable proxy mode only when Odoo is behind a trusted reverse proxy.
Step 3 — Create the Nginx Configuration
Create a new configuration file:
sudo nano /etc/nginx/sites-available/odoo
Add the following configuration:
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;
client_max_body_size 100M;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
location /websocket {
proxy_pass http://odoochat;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $http_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_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $http_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;
}
}
Replace erp.example.com with your actual domain.
Important: This example assumes Odoo is running in multi-worker mode with a dedicated WebSocket service on port 8072. For single-threaded deployments, WebSocket routing must be adapted to the actual Odoo server configuration.
Step 4 — Enable the Nginx Configuration
Create a symbolic link:
sudo ln -s /etc/nginx/sites-available/odoo \ /etc/nginx/sites-enabled/odoo
Check the configuration:
sudo nginx -t
If the test succeeds, reload Nginx:
sudo systemctl reload nginx
Your Odoo instance should now be accessible through:
http://erp.example.com
Step 5 — Enable HTTPS with Let's Encrypt
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Generate an SSL certificate:
sudo certbot --nginx -d erp.example.com
Follow the instructions to complete the SSL configuration and enable HTTP-to-HTTPS redirection. After successful installation, access Odoo using:
https://erp.example.com
Verify automatic certificate renewal:
sudo certbot renew --dry-run
Ensure ports 80 and 443 are accessible for the required HTTP validation and HTTPS traffic.
Step 6 — Test the Configuration
Open your browser and access the Odoo domain.
Verify that:
- Odoo loads successfully through HTTPS.
- Login and logout work correctly.
- Website pages and backend menus load normally.
- Discuss notifications and other real-time features work.
- Browser console and server logs show no critical proxy errors.
You can monitor Nginx errors using:
sudo tail -f /var/log/nginx/error.log
Common Issues and Solutions
| Issue | Recommended Solution |
| 502 Bad Gateway | Verify Odoo service and port 8069 |
| 504 Gateway Timeout | Check Odoo processing time and proxy timeout |
| WebSocket Connection Failed | Verify port 8072, worker mode, and Upgrade headers |
| HTTPS Not Working | Check DNS, firewall, and SSL certificate |
| Redirect Loop | Verify proxy_mode and forwarded HTTPS headers |
| Large File Upload Failed | Adjust client_max_body_size |
Conclusion
Configuring Nginx as a reverse proxy is an important step toward deploying Odoo in a production environment. With proper reverse proxy configuration, HTTPS encryption, and WebSocket routing, organizations can provide secure and reliable access to their Odoo ERP system. For production environments, additional security hardening, monitoring, backups, and performance optimization are recommended.
Need Help Deploying Odoo ERP?
DUO Digital Solusindo provides professional services for Odoo ERP implementation, server deployment, performance optimization, customization, and technical support.
Expert People. Smart Solutions. Trusted Partnership.