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 *:80>
ServerAdmin [email protected]
ServerName yourdomain.com
ServerAlias www.yourdomain.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://127.0.0.1:8069/
ProxyPassReverse http://127.0.0.1:8069/
</Location>
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:8069/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://127.0.0.1:8069/$1 [P,L]
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</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.
2 Comments
The config is missing 🙂
Thanks for pointing it out. It as a missing quote (“) causing issue. Fixed now.