Setting Up Apache2 to Reverse Proxy Odoo on a Ubuntu Server / VPS
When running Odoo on a VPS with Ubuntu, the default configuration typically allows access via https://server_ip_address:8069
. However, you might want to simplify this to just https://server_ip_address
or https://server_ip_address/web
using Apache2 as a reverse proxy. This guide walks you through the necessary steps to achieve this.
Understanding Ports and Reverse Proxy
Odoo by default listens on port 8069. By using Apache2 as a reverse proxy, we can direct traffic from the default HTTP port (80) to Odoo’s port (8069). This means users can access Odoo without needing to specify the port in the URL, providing a cleaner and more user-friendly URL.
Step 1: Install Apache2
Apache2 is a popular open-source web server. If you haven’t already installed Apache2, you can do so by running the following commands:
sudo apt update
sudo apt install apache2
The sudo apt update
command updates your package list to the latest versions, and sudo apt install apache2
installs the Apache2 web server.
Step 2: Enable Necessary Apache Modules
To use Apache as a reverse proxy, we need to enable several modules:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod rewrite
proxy
: Enables the proxy feature in Apache.proxy_http
: Enables the HTTP proxy module.headers
: Allows you to use HTTP headers.rewrite
: Enables URL rewriting.
After enabling these modules, restart Apache to apply the changes:
sudo systemctl restart apache2
Step 3: Configure Apache for Odoo
We need to create a configuration file for our Odoo setup:
sudo nano /etc/apache2/sites-available/odoo.conf
Add the following configuration to the file. Replace YOUR_SERVER_IP
with your VPS's IP address:
<VirtualHost *:80>
#ServerAdmin admin@yourdomain.com
ServerName YOUR_SERVER_IP
ProxyRequests Off
ProxyPass / http://localhost:8069/
ProxyPassReverse / http://localhost:8069/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
Order allow,deny
Allow from all
</Location>
ErrorLog ${APACHE_LOG_DIR}/odoo_error.log
CustomLog ${APACHE_LOG_DIR}/odoo_access.log combined
</VirtualHost
This configuration tells Apache to listen on port 80, and forward all requests to localhost:8069
where Odoo is running. ProxyPass
and ProxyPassReverse
are directives that configure the reverse proxy.
Step 4: Enable the Odoo Site Configuration
Enable the new site configuration and disable the default site:
sudo a2ensite odoo.conf
sudo a2dissite 000-default.conf
a2ensite odoo.conf
: Enables the new Odoo site configuration.a2dissite 000-default.conf
: Disables the default Apache site configuration.
Step 5: Restart Apache
To apply your new configuration, restart Apache:
sudo systemctl restart apache2
Step 6: Accessing Odoo
You should now be able to access Odoo using your VPS’s IP address in a web browser. Simply type http://YOUR_SERVER_IP
in your browser's address bar, where YOUR_SERVER_IP
is your VPS's IP address.
Step 7: Configure the Firewall
Check Firewall Status
First, check if the firewall is active on your Ubuntu server. The default firewall for Ubuntu is UFW (Uncomplicated Firewall):
sudo ufw status
This command will display the current status of the firewall.
Allow Apache Through Firewall
Since you are using Apache as a reverse proxy for Odoo, you need to allow Apache through the firewall. Apache registers a few profiles with UFW. You can allow traffic on port 80 (HTTP) with the following command:
sudo ufw allow 'Apache'
This command enables traffic for the Apache service, which includes the necessary ports.
Enable the Firewall
If the firewall is not active, enable it:
sudo ufw enable
This command activates the firewall, applying all the configured rules.
Check the Updated Firewall Status
Finally, check the status again to ensure your rules are active:
sudo ufw status
This command will show you the active firewall rules, confirming that Apache traffic is allowed.
Step 8: Fix Fully Qualified Domain Name (FQDN) Warning
If you encounter the warning AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally
, follow these steps:
Open the Apache2 Configuration File
sudo nano /etc/apache2/apache2.conf
Set the Global ServerName
Add a line at the bottom of this file with your server’s IP address or a dummy FQDN:
ServerName YOUR_SERVER_IP
Replace YOUR_SERVER_IP
with your server's public IP address.
Save and Close the File
After adding the line, save the file and exit the editor.
Restart Apache
To apply the changes, restart Apache:
sudo systemctl restart apache2
Check the Status Again
Finally, check the status of Apache again to ensure the warning is gone:
systemctl status apache2
Additional Notes
Accessing Odoo: You can now access Odoo using your server’s IP address: http://YOUR_SERVER_IP/web
.
Firewall Considerations: If you’re accessing the server via SSH, make sure to allow SSH (port 22) through the firewall before enabling it to avoid locking yourself out of the server:
sudo ufw allow ssh
By following these steps, you can successfully set up Apache2 as a reverse proxy for Odoo on your VPS, allowing easier access and improved management of your Odoo instance.
More (related) :
- https://www.cybrosys.com/blog/how-to-configure-odoo-with-apache-2-as-reverse-proxy-in-ubuntu
- https://www.odoo.com/fr_FR/forum/aide-1/how-do-i-turn-off-the-powered-by-odoo-text-in-the-footer-of-a-website-199187