How to Configure Odoo with Nginx as a Reverse Proxy

How to Configure Odoo with Nginx as a Reverse Proxy

If you’re managing an Odoo instance in a production environment, it’s crucial to ensure optimal performance, secure connections, and scalability. One of the most effective ways to achieve this is to configure Odoo with Nginx as a reverse proxy, which enhances speed, security, and overall system reliability by efficiently managing client requests and SSL termination.

In this article, we’ll explore why you should use Nginx with Odoo, how to configure it step-by-step, and share tips to optimize performance and security. This guide is ideal for Odoo consultants, developers, and business owners looking to build a reliable deployment setup.

What is a Reverse Proxy

A reverse proxy acts as an intermediary server between the client (browser) and your application (Odoo). Instead of accessing Odoo directly through its default port (usually 8069), The reverse proxy listens on standard HTTP/HTTPS ports (80/443), and forwards the request to Odoo internally.

Why Use Nginx as a Reverse Proxy for Odoo?

Here are several reasons why configuring Nginx in front of Odoo is a best practice:

  • Security: Enables SSL termination with HTTPS
  • Performance: Offloads static file delivery (JS, CSS, images)
  • URL Handling: Provides cleaner, user-friendly URLs
  • Load Balancing: Future scalability for multiple Odoo workers or instances
  • Domain Management: Host multiple services on the same server

Let’s now set up Odoo with Nginx step by step.

Step-by-Step to Configure Odoo with Nginx as Reverse Proxy

Here are the steps to configure odoo with Nginx as a reverse proxy:

Step 1: Install Nginx on Your Server

First, make sure Nginx is installed on your Ubuntu server. You can do this with:

sudo apt update
sudo apt install nginx

After installation, enable and start the Nginx service:

sudo systemctl enable nginx
sudo systemctl start nginx

To verify it’s running:

sudo systemctl status nginx

You should see “active (running)” in the output.

Step 2: Basic Odoo Setup (Assumed Preconfigured)

This guide assumes that:

  • Odoo (e.g., Odoo 16, 17, or 18) is installed and running on localhost:8069
  • Odoo is accessible via your server’s public IP: http://your_domain_or_ip:8069

Follow this article to install Odoo on your system:

>> How to Install Odoo 17 on Windows

Now let’s make it accessible via a domain (e.g., https://erp.yourdomain.com) using Nginx.

Step 3: Configure Odoo with Nginx as a Reverse Proxy

Let’s create a new server block (virtual host) in Nginx. This configuration listens on port 80 and forwards traffic to Odoo on port 8069.

Create a new config file

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

Paste this configuration

server {
    listen 80;
    server_name erp.yourdomain.com;

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

    # Log files
    access_log /var/log/nginx/odoo.access.log;
    error_log /var/log/nginx/odoo.error.log;

    # Gzip settings (Optional)
    gzip on;
    gzip_types text/css application/javascript image/svg+xml;

    # Forward requests to Odoo backend
    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;
    }

    # Static files (Optional optimization)
    location ~* /web/static/ {
        proxy_cache_valid 200 90m;
        proxy_buffering on;
        expires 864000;
        proxy_pass http://127.0.0.1:8069;
    }

    # Long polling (Live chat, etc.)
    location /longpolling/ {
        proxy_pass http://127.0.0.1:8072;
        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;
    }
}

Make sure to replace erp.yourdomain.com With your actual domain name.

Step 4: Enable the Site and Restart Nginx

Create a symbolic link to activate the config:

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

Test your Nginx configuration to ensure there are no syntax errors:

sudo nginx -t

If all is good, restart Nginx:

sudo systemctl restart nginx

Now, accessing http://erp.yourdomain.com should load your Odoo instance via Nginx.

To secure your site, use Let’s Encrypt with Certbot.

Install Certbot

sudo apt install certbot python3-certbot-nginx

Generate and apply an SSL certificate

sudo certbot --nginx -d erp.yourdomain.com

Certbot will:

  • Obtain an SSL certificate
  • Automatically configure your Nginx server block
  • Redirect HTTP to HTTPS

Don’t forget to renew your certificate automatically:

sudo certbot renew --dry-run

Optional: Redirect All HTTP to HTTPS

If Certbot didn’t auto-redirect, manually edit your odoo config and add:

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

This ensures that all traffic is encrypted.

Bonus Tips for Production-Grade Odoo Deployments

As an Odoo consultant, here are some practical tips to enhance your deployment:

Use workers for better performance

Odoo runs in threaded mode by default. For production, configure odoo.conf to use workers:

workers = 4
limit_memory_hard = 2684354560  ; 2.5GB
limit_time_cpu = 60
limit_time_real = 120

Monitor Logs

Keep an eye on both Odoo and Nginx logs:

tail -f /var/log/nginx/odoo.error.log
tail -f /var/log/nginx/odoo.access.log

And for Odoo logs (typically in /var/log/odoo/).

Related Blogs:

>> What is Odoo Runbot and How to Access It?

>> Understanding OWL JS Lifecycle Hooks in Odoo 17

Why this Configure Odoo with Nginx Matters

Using Nginx as a reverse proxy for Odoo is more than a convenience—it’s a smart strategy for security, performance, and scalability. With this setup:

  • Your ERP is accessible via a clean domain (https://erp.yourdomain.com)
  • All traffic is encrypted using HTTPS
  • Static content is served faster
  • You’re ready to scale to a multi-worker or multi-instance deployment

Final Words – Configure Odoo with Nginx

Configuring Odoo with Nginx as a reverse proxy is one of the smartest decisions you can make when moving your Odoo deployment to production. It not only improves performance and security but also prepares your infrastructure for future scalability and professional-grade stability.

Whether you’re a developer, system admin, or business owner managing an Odoo ERP system, integrating Nginx into your stack ensures you’re following best practices in the industry. From enabling HTTPS with Let’s Encrypt to efficiently routing traffic and serving static assets, this setup gives you full control and flexibility over how your Odoo runs online.

As your business grows, a reverse proxy with Nginx will continue to serve as a robust gateway, keeping your ERP accessible, secure, and high-performing.

Go ahead and implement this configuration to take your Odoo deployment to the next level. If you found this guide helpful, don’t forget to share it or bookmark it for future reference!

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.