Enable Dark Mode!
how-to-configure-odoo-with-apache-2-as-reverse-proxy-in-ubuntu.jpg
By: Hajaj Roshan

How to Configure Odoo with Apache 2 as Reverse Proxy in Ubuntu

Technical Odoo 15

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!”

how-to-configure-odoo-with-apache-2-as-reverse-proxy-in-ubuntu

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.


If you need any assistance in odoo, we are online, please chat with us.



1
Comments

Melvin

although apache getting the real IP but All odoo log getting visitor IP from 127.0.0.1 , looks like my apache not forwarding the IP through proxy ##Odoo.log## 2023-08-14 20:17:01,697 2169 INFO od16080502 werkzeug: 127.0.0.1 - - [14/Aug/2023 20:17:01] "GET /websocket HTTP/1.1" 400 - 1 0.000 0.002 2023-08-14 20:17:19,536 2171 INFO od16080502 werkzeug: 127.0.0.1 - - [14/Aug/2023 20:17:19] "GET /websocket HTTP/1.1" 400 - 1 0.000 0.002 ##Odoo.log## ##Apache access log# 152.58.221.36 - - [14/Aug/2023:23:10:39 +0300] "GET /websocket HTTP/1.1" 503 299 "-" "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36 EdgA/115.0.1901.196" 152.58.221.36 - - [14/Aug/2023:23:10:41 +0300] "GET /web HTTP/1.1" 503 299 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203" 152.58.221.36 - - [14/Aug/2023:23:10:48 +0300] "GET /websocket HTTP/1.1" 503 299 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203" 152.58.221.36 - - [14/Aug/2023:23:11:04 +0300] "GET /web HTTP/1.1" 503 299 "-" "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36 EdgA/115.0.1901.196" ##Apache access log# ##Apache httpd config## /usr/local/apache/conf/httpd.conf # mod_remoteip activated by melvin 20230814 RemoteIPTrustedProxy 127.0.0.1 RemoteIPHeader X-Forwarded-For RemoteIPInternalProxy 0.0.0.0/24 RemoteIPInternalProxy 127.0.0.0/24 RemoteIPInternalProxy 192.168.0.0/24 RemoteIPInternalProxy 192.168.10.1/24 RemoteIPInternalProxy 192.168.10.4/24 RemoteIPInternalProxy 127.0.0.1/24 LoadModule remoteip_module modules/mod_remoteip.so # mod_remoteip activated by melvin 20230814 ##Apache httpd config## ##Vhost config## ProxyRequests Off ProxyPreserveHost On ProxyVia Full ProxyPass / %proxy_protocol%://%proxy_ip%:%proxy_port%/ ##option 1 - works## roxyPassReverse / %proxy_protocol%://%proxy_ip%:%proxy_port%/ ##option 1 - works## # ProxyPass / http://%proxy_ip%:%proxy_port%/ ##option 2 - works## # ProxyPassReverse / https://%domain%:%apache_port%> ##option 2 - works## AllowOverride All ##Vhost config##

14/08/2023

-

8:23PM



Leave a comment



whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message