Installing Apache2 as Reverse Proxy for Odoo

Introduction

Setting up Apache2 as a reverse proxy for Odoo offers several advantages that enhance both performance and security.

Firstly, a reverse proxy can help manage incoming traffic more efficiently, distributing requests to Odoo’s backend server while handling SSL termination, which secures data transmission. This setup allows for better load balancing and can improve response times for users.

Secondly, using Apache as a reverse proxy can simplify the management of multiple applications on the same server. It allows you to serve Odoo alongside other web applications without port conflicts, all under a single domain.

Lastly, it adds an additional layer of security by hiding the backend server’s details from the public, making it harder for potential attackers to target the Odoo instance directly. Overall, this configuration enhances the robustness and scalability of your Odoo deployment.

To install Apache2 as a reverse proxy for Odoo, follow these steps. This guide assumes you are using a Debian-based system like Ubuntu.

Step 1: Install Apache2

First, you need to install Apache2 if it is not already installed. Open your terminal and run:

sudo apt update
sudo apt install apache2

Step 2: Enable Required Apache Modules

You need to enable the necessary Apache modules for reverse proxy functionality. Run the following commands:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo systemctl restart apache2

Step 3: Configure Apache as a Reverse Proxy

Create a new configuration file for your Odoo site. You can name it odoo.conf:

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

Instead of vim use nano for a simpler editor.

Add the following configuration to the file, replacing your_domain_or_ip with your actual domain name or IP address:

<VirtualHost *:80>
    ServerName your_domain_or_ip

    ProxyRequests Off
    ProxyPass / http://localhost:8069/
    ProxyPassReverse / http://localhost:8069/

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ErrorLog ${APACHE_LOG_DIR}/odoo_error.log
    CustomLog ${APACHE_LOG_DIR}/odoo_access.log combined
</VirtualHost>

Step 4: Enable the New Site Configuration

Enable the new site configuration and reload Apache:

sudo a2ensite odoo.conf
sudo systemctl reload apache2

Step 5: Adjust Odoo Configuration (if necessary)

Make sure that Odoo is configured to allow connections from the Apache server. You may need to adjust the odoo.conf file (usually located in /etc/odoo/) to include the following line:

proxy_mode = True

Step 6: Restart Odoo

After making changes to the Odoo configuration, restart the Odoo service:

sudo systemctl restart odoo

Step 7: Test the Configuration

Open your web browser and navigate to http://your_domain_or_ip (without the port number 8069). You should see the Odoo interface served through Apache.

Conclusion

You have successfully set up Apache2 as a reverse proxy for Odoo. This configuration allows you to serve Odoo through a standard web server, which can help with performance and security. As a next step you can setup now https. If you have any specific questions or run into issues, feel free to ask!

This Post Has 2 Comments

  1. Vincèn

    What about the port 8072 that needs to be proxied also for the chatter ???

    1. nilsnop

      Yes, you’re right. By adding the directives for port 8072, your Apache server will successfully proxy WebSocket connections, allowing users to enjoy the real-time chat features of Odoo. This is essential for a fully functioning Odoo experience, especially if leveraging the chatter functionality. Example of odoo.conf:

      ServerName your_domain_or_ip

      ProxyRequests Off
      ProxyPass / http://localhost:8069/
      ProxyPassReverse / http://localhost:8069/

      ProxyPass /longpolling/ http://localhost:8072/
      ProxyPassReverse /longpolling/ http://localhost:8072/

      Order deny,allow
      Allow from all

      ErrorLog ${APACHE_LOG_DIR}/odoo_error.log
      CustomLog ${APACHE_LOG_DIR}/odoo_access.log combined

Leave a Reply