In this blog, we are going to check how to set up a reverse proxy in Odoo using Apache 2. So if you have not installed Odoo, please refer to the following blogs to install different versions of Odoo.
How to Install Odoo 15 on Ubuntu 20.04
How to Install Odoo 14 on Ubuntu 20.04
How to Install Odoo 13 on Ubuntu 20.04
After successful installation of Odoo, you can access your Odoo instance using domain or IP address along with the port number, which by default is 8069 for Odoo. So, if you want to access your Odoo instance only with your domain or IP address, reverse proxy will help it. Lets’ look at how to configure Apache 2 for reverse proxy in Odoo
Step1: Install Apache 2 on your server
Open a terminal and run the command
sudo apt install apache2
After installing Apache 2, enable the apache service to automatically start from the boot using the following command.
sudo systemctl enable apache2
You can verify, Apache 2 is working properly on the server by opening the browser and just entering your IP address or domain name. So, If the Apache 2 runs perfectly, you can see a message “It Works!”
Next enable Apache 2 proxy and proxy_http modules
a2enmod proxy
a2enmod proxy_http
Now we can create a new configuration file for the domain. Ensure that filename with your complete domain name with .conf extension.
For eg: if your domain is cybrosys.com, then your file name should be cybrosys.com.conf
nano /etc/apache2/sites-available/example.domain.com.conf
Replace example.domain.com with your domain name.
This command will open a new file in Terminal. Add the following lines into it.
<VirtualHost *:80>
ServerName example.domain.com
ServerAlias example.domain.com
ProxyRequests Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://example.domain.com:8069/
ProxyPassReverse / http://example.domain.com:80>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
<Location />
Require all granted
</Location>
</VirtualHost>
Replace example.domain.com in the above lines with your actual domain name.
Then we have to enable the newly created configuration, using the following command.
a2ensite yourdomain.com
Configurations are completed. Now restart Apache 2 service
service apache2 restart
Now you can directly access your Odoo instance with your domain name itself. Apache will redirect HTTP requests to Odoo. Now you will be able to use Odoo without a port number.