Odoo is one the of most popular business software in the world and is packed with multiple useful modules like 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.
- In order to access your Odoo application only by using your domain name, 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 like Apache installed on the VPS. If Apache web server is running, stop it:
systemctl stop apache2
and remove it:
apt-get purge apache2*
apt autoremove
NGINX web server
- Nginx is free and open source web server/software, which can also be used as a reverse proxy, load balancer and HTTP cache. A large fraction of web servers use NGINX.
- Install NGINX on Ubuntu
On Ubuntu (and other Debian based Linux distributions), run:
sudo apt-get update
sudo apt-get install nginx
- Start NGINX
Start the nginx service with the following command:
sudo service nginx start
Change the binding interface
- This step is optional, but it is a good security practice. 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 at the end of the file:
/etc/odoo.conf
xmlrpc_interface = 127.0.0.1
netrpc_interface = 127.0.0.1
- Save the configuration file and restart the Odoo server for the changes to take effect:
systemctl restart odoo
Configure NGINX
- Edit the current nginx server block about the old domain or create a new server block if it is not created yet.
- Add the following lines:
Cd /etc/nginx/sites-enabled
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;
}
Restart NGINX
- Do not forget to restart the nginx service for the changes to take effect:
service nginx restart