Odoo is one of the most popular business management ERP software in the world. Moreover, having a modular approach to option in the company the platform is packed with multiple useful modules such as Customer Relationship Management (CRM), Point of Sale, Project Management, Inventory Management, Automated Invoicing, Accounting, E-commerce, and much more.
This blog provides instructions on how to use Nginx as a reverse proxy to Odoo.
- Initially, in order to access your Odoo application only by using your domain name, and without the port number in the URL, we need to set up Nginx as a reverse proxy.
- Before installing the Nginx web server, make sure that there is no other web server such as Apache installed on the VPS. If the Apache web server is running, stop it using the following command:
systemctl stop apache2
Furthermore, you can remove it using the following command:
apt-get purge apache2*
apt autoremove
As we have stopped and removed other servers from functioning now let's move on to installing aspects of NGINX
NGINX web server
- Nginx is a free and open source web server/software, which can also be used as a reverse proxy, load balancer and HTTP cache. Additionally, a large fraction of web servers use NGINX.
Now lets under tsnd how to install NGINX in ubuntu or other Debian based Linux distributions
- Install NGINX on Ubuntu
For installing NGINX on Ubuntu (and other Debian based Linux distributions), run the following command:
sudo apt-get update
sudo apt-get install nginx
- Start NGINX
Start the Nginx service with the use of the following command:
sudo service nginx start
Change the binding interface
- Although this step is optional, it is a good security practice. Moreover, by default Odoo server listens to port 8069 on all interfaces, so if you want to disable the direct access to your Odoo instance, open the Odoo configuration and add the following two lines of command at the end of the file:
sudo nano /etc/odoo.conf
xmlrpc_interface = 127.0.0.1
netrpc_interface = 127.0.0.1
- Now save the configuration file and restart the Odoo server for the changes to take effect using the following code:
systemctl restart odoo
As the NGINX is installed and the binding interface is changed let's now move on to configuring it in the next section.
Configure NGINX
- Initially edit the current Nginx server block in the old domain or create a new server block if it is not created yet.
- Now add the following lines of code to configure NGINX:
sudo nano /etc/nginx/sites-enabled/default
server {
server_name testing.com 111.111.111.111; //replace ip and server name with your domain and ip
listen 80;
access_log /var/log/nginx/testing-access.log;
error_log /var/log/nginx/testing-error.log;
location /longpolling {
proxy_connect_timeout 3600;
proxy_read_timeout 3600;
proxy_send_timeout 3600;
send_timeout 3600;
proxy_pass http://127.0.0.1:8072;
}
location / {
proxy_connect_timeout 3600;
proxy_read_timeout 3600;
proxy_send_timeout 3600;
send_timeout 3600;
proxy_pass http://127.0.0.1:8069/;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
gzip on;
gzip_min_length 1000;
}
upstream odoo {
server 127.0.0.1:8069 weight=1 fail_timeout=0;
}
upstream odoo-im {
server 127.0.0.1:8072 weight=1 fail_timeout=0;
}
As the NGINX is configured lets now restart the server for the configuration to be effective.
Restart NGINX
- Restart the Nginx service using the following code for the changes to take effect:
service nginx restart
Following the above-mentioned steps will help you to easily configure the Odoo platform with Nginx as Reverse Proxy