Skip to content

How to Configure Apache as Reverse Proxy for Odoo

Advertisement

Odoo is a collection of business-related applications and software tools that can help manage different parts of a company, such as inventory, billing, manufacturing, and human resources. It’s like a big toolbox that helps businesses to choose a tools based on their requirements to run more smoothly and efficiently. You can think of Odoo as a customizable kit that helps companies handle all their various tasks in one place.

Odoo usually uses port 8069 to operate, but you can change this if you need to. If you want a front-end web server that receives requests on port 80 or 443 and sends them to Odoo running in the background, this tutorial is for you. It will guide you on how to set up Apache as a front-end reverse proxy server. This setup helps direct user requests from the web server to Odoo.

Step-by-Step Guide

Setting up an Apache reverse proxy for Odoo requires a few steps. Here’s a simple guide to help you get started. First, make sure Apache is installed on your server and that Odoo is running on its usual port, which is often 8069. You’ll also need to enable the mod_proxy and mod_proxy_http modules in Apache

Let’s follow the step-by-step instructions to setup it:

Step 1: Enable Apache Modules

Ensure that all the necessary modules are enabled in Apache. You can do this by running the following commands:

sudo a2enmod proxy proxy_http proxy_html headers rewrite 

Then restart Apache web server:

sudo systemctl restart apache2 

Step 2: Configure the VirtualHost for Odoo

You need to set up a virtual host file in Apache that will forward requests to the Odoo application.

Let’s make a new configuration file in the ‘sites-available’ directory of Apache. Here’s how you can do it:

sudo nano /etc/apache2/sites-available/odoo.conf 

Then, add the following configuration, adjusting the domain name and port number to match your setup:


<VirtualHost *:443>
    ServerName yourdomain.com

    # Security Headers
    Header always set Strict-Transport-Security "max-age=2592000"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"

    # Logs
    ErrorLog ${APACHE_LOG_DIR}/odoo-ssl-error.log
    CustomLog ${APACHE_LOG_DIR}/odoo-ssl-access.log combined

    # Proxy settings for Odoo main HTTP port (8069)
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8069/
    ProxyPassReverse / http://127.0.0.1:8069/

    # Proxy for longpolling (WebSocket, port 8072)
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/longpolling/(.*) ws://127.0.0.1:8072/longpolling/$1 [P,L]
    ProxyPass /longpolling/ http://127.0.0.1:8072/longpolling/
    ProxyPassReverse /longpolling/ http://127.0.0.1:8072/longpolling/

    # Proxy headers for Odoo
    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-Host "%{HTTP_HOST}s"
    RequestHeader set X-Real-IP "%{REMOTE_ADDR}s"
    RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}s"

    # Static file handling (e.g., /web/static/)
    <Location "/web/static/">
        ProxyPass !
        # Serve directly from Odoo's static directory (adjust path if needed)
        Alias /web/static/ /path/to/odoo/addons/web/static/
        <Directory /path/to/odoo/addons/web/static/>
            Options -Indexes
            AllowOverride None
            Require all granted
            # Optional: Add caching
            ExpiresActive On
            ExpiresByType text/css "access plus 1 month"
            ExpiresByType image/* "access plus 1 month"
            ExpiresByType application/javascript "access plus 1 month"
        </Directory>
    </Location>

    # Increase timeout for longpolling and file uploads
    ProxyTimeout 3600
    Timeout 3600
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>

    # Gzip compression
    <IfModule mod_deflate.c>
        SetOutputFilter DEFLATE
        AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
        AddOutputFilterByType DEFLATE application/javascript application/json application/xml
        AddOutputFilterByType DEFLATE image/svg+xml
    </IfModule>
</VirtualHost>

In this configuration:

  • Replace yourdomain.com with your actual domain.
  • ProxyPass and ProxyPassReverse directives are used to forward requests to Odoo running on port 8069.
  • The Rewrite rules are for handling WebSocket connections which are used by some Odoo features.

Step 3: Enable the Virtual Host

After saving the file, you can activate the site with this command:

sudo a2ensite odoo.conf 

Step 4: Restart Apache

To apply the changes, restart Apache:

sudo systemctl restart apache2 

Step 5: Additional Security

Consider setting up HTTPS using Let’s Encrypt or another SSL provider for added security. This involves obtaining an SSL certificate and adjusting the Apache configuration to handle HTTPS requests.

You can also get free SSL certificates from Let’s Encrypt. You can do this by Generating SSL using Certbot.

Step 6: Odoo Configuration

Make sure that Odoo is configured to work behind a proxy. In the Odoo configuration file (/etc/odoo/odoo.conf), you might need to set the proxy_mode parameter to True:


proxy_mode = True

After you make these updates, remember to restart the Odoo service to activate the changes.

Once you’ve followed these steps, you should be able to access your Odoo system through the domain you set up, with Apache working as a reverse proxy. Make sure to update any placeholder values with your actual domain and port information. Also, check that your firewall settings permit traffic on the relevant ports.

Conclusion

To wrap up, setting up Apache to forward requests to Odoo involves creating a virtual host configuration file. This file tells Apache how to handle web traffic and send it to Odoo so that your Odoo application can respond to requests properly. Once you have this configuration in place, Apache will act as a middleman, efficiently directing traffic to Odoo, helping your system manage web interactions smoothly.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

5 Comments

  1. Hi
    Thanks for this tutorial. I have a few questions.
    Here’s my setting:
    – odoo running on local server only accessible by lan (testing only)
    – other services are running on the server, some of them behind an apache reverse proxy.

    I had to make two changes:
    – remove url-path from Alias directive since it’s in a Location directive
    – move Directory section out of Location.
    This seems to conform to Apache documentation, which would load otherwise. So I ended up with:

    Options -Indexes
    AllowOverride None
    Require all granted
    # Optional: Add caching
    ExpiresActive On
    ExpiresByType text/css “access plus 1 month”
    ExpiresByType image/* “access plus 1 month”
    ExpiresByType application/javascript “access plus 1 month”

    ProxyPass !
    Alias /path/to/odoo/addons/web/static/

    What do you think of that?

    Since I will not use SSL on lan I tried to include this configuration in along with other services. I wanted /odoo to proxy to default localhost:8069. So I end up with:
    # Proxy
    ProxyPreserveHost On
    ProxyPass /odoo/ http://localhost:8069/odoo/
    ProxyPassReverse /odoo/ http://localhost:8069/odoo/
    RequestHeader set X-Forwarded-Proto http
    RequestHeader set X-Forwarded-Prefix /odoo/

    # Proxy for longpolling (WebSocket, port 8072)
    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteCond %{HTTP:Connection} upgrade [NC]
    RewriteRule ^/longpolling/(.*) ws://localhost:8072/longpolling/$1 [P,L]
    ProxyPass /longpolling/ http://localhost:8072/longpolling/
    ProxyPassReverse /longpolling/ http://localhost:8072/longpolling/

    When I hit http://myserver.local/odoo/ in my web browser I get this in the terminal where I started odoo on the server:
    2026-01-24 08:58:21,263 2425551 INFO odoo werkzeug: 192.168.1.21 – – [24/Jan/2026 08:58:21] “GET /odoo/ HTTP/1.1” 200 – 20 0.011 0.029
    But the page stays blank.
    Hitting http://myserver.local:8069/ still works fine through.

    Not sure what I’m doing wrong ^^ reverse proxies are still kind of dark magic to me especially when they involve websockets…
    Cheers

Leave a Reply

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


Back to top