Odoo is a suite of business management software tools including CRM, e-commerce, billing, accounting, manufacturing, warehouse, project management, and inventory management, and point of sale and much more. It is also widely popular ERP software solutions for small and medium enterprise as it offers high flexibility and comprehensive solution and provides convenient tools for managing business process.
Odoo has it’s own built in web server. After installation in order to access it you need to indicate the port number you defined on the configuration file i.e(http://127.0.0.1:8069).
But for production it is recommended to setup a reverse proxy. Reverse proxy will provide users easy access to the Odoo instance through a domain without the need to include the port number. The reverse proxy will act as the middle man between the clients and the Odoo server.
In this tutorial we will demonstrate how to configure Odoo with the two most popular web servers Apache and Nginx as reverse proxy.
Let us start.
Prerequisites
- Ubuntu 22.04
- A running Odoo instance
- A domain and the DNS A record should be pointed your server where the reverse proxy is setup.
Apache as reverse proxy
Apache is one of the most popular web server, and the benefits of having a reverse proxy with Apache is to have flexibility to secure your instance, set up load balancing, and web caching and many more.
We assumed that Apache is already installed.
First let us create a virtual host where we will define the directives for reverse proxy.
sudo nano /etc/apache2/sites-available/example.com.conf
Insert the following information to the virtual host.
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8069/
ProxyPassReverse / http://localhost:8069/
<Location />
Order deny,allow
Deny from all
Allow from all
</Location>
</VirtualHost>
We assumed on the configuration file that your instance is using port 8069. Don’t forget also to change the example.com to your actual domain. Save the configuration file and exit.
Now let us enable the Apache proxy modules.
sudo a2enmod proxy && sudo a2enmod proxy_http
Now enable the virtual host configuration file.
sudo a2ensite example.com.conf
Restart the Apache web server.
sudo systemctl restart apache2
Now you should be able to access your Odoo instance on your browser with your domain(http://example.com).
Nginx as reverse proxy
Nginx is a fast, high performance and light weight web server and also offers load balancing, reverse proxy with caching and many more.
We also assumed that Nginx is already installed.
Let us start and create a server block or an nginx configuration file.
sudo nano /etc/nginx/sites-available/example.com.conf
Insert the following information to the server block
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
server {
server_name example.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
location /longpolling {
proxy_pass http://odoochat;
}
location / {
proxy_pass http://odoo;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}
# common gzip
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
We also assumed on the configuration file that your instance is using port 8069 and your longpolling port is 8072. Don’t forget to change the example.com to your actual domain. Save the configuration file and exit.
Let us enable the nginx configuration file(server block) .
sudo ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/
Restart Nginx.
sudo systemctl restart nginx
You should be able to access your Odoo instance through your domain http://example.com.
Conclusion
You are able to learn how to configure Odoo with Apache and Nginx as reverse proxy. If you want to install SSL certificate to secure your website you can check our tutorial with Let’s Encrypt.
Thank you and hope you enjoy our tutorial ?