We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« Back to Blogs

Configure Nginx Web Server With Odoo As A Reverse Proxy

Configure Nginx Web Server with Odoo
 
In today’s digital era, an ERP system has become one of the critical business needs in streamlining operations and driving business growth. And Odoo is one of the most popular and robust ERP systems that offer all-in-one solutions for your business needs.
 
By default, Odoo runs on port 8069, and we connect to the server using domain: 8069. If we need to access the server using only a domain like a standard website, we need to configure the web server with Odoo.
 
This blog describes in-depth instructions on how to configure the Nginx web server for Odoo.
 
 
However, before we go through the steps to configure the Nginx web server, let’s have a brief on a web server and web server as a reverse proxy. 

What is a reverse proxy server?

A reverse proxy server is a web server that acts as an intermediary between your application server and the client. It forwards requests or content from multiple client servers across the internet.
 
In our case, the Nginx server acts as a mediator between the client and the Odoo application server. 

Advantages of the reverse proxy server

  • Load balancing
  • Increased security
  • SSL Termination
  • Caching 
  • Serving Static Content

Configure Nginx Web Server as a Reverse Proxy with Odoo

Step- 1: Install Nginx

Before configuring Odoo with Nginx, install the Nginx web server by executing the following commands.
sudo apt update 

 

sudo apt install Nginx  
 
After installing Nginx on your machine, you need to check whether Nginx is installed successfully or not. 

Step- 2: Check Nginx Status

To check, execute the command below.
sudo systemctl status nginx 

 

After successfully installing Nginx, you will have to start Nginx service and for that, execute the below command.

Step- 3: Start Nginx

sudo systemctl start nginx 
 
Now, you have to create an Nginx config file for your domain name. The filename should be the same as your domain name. 

Step- 4: Configure Nginx

Ex: odoo.example.com
 
For creating a config file, please execute the below command.
 cd /etc/nginx/sites-available  

 

sudo nano odoo.example.com  

 

After creating the file, add the below command and save.

 

 server {   

    listen 80;   

    server_name odoo.example.com;   

    access_log /var/log/nginx/odoo.example.access.log;   

    error_log /var/log/nginx/odoo.example.error.log;   

    location / {   

        proxy_pass http://127.0.0.1:8069;   

    }   
} 

 

Now, link your conf file from sites-available to sites-enabled by executing the below command.

 

sudo ln -s /etc/nginx/sites-available/odoo.example.com /etc/nginx/sites-enabled/odoo.example.com 

 

If the sites-enabled folder contains a default configuration file then remove it, as it is not required.

 

sudo rm -f /etc/nginx/sites-enabled/default 

 

Now, since our configuration for Nginx is completed, we need to restart the Nginx server by executing the below command.

 

sudo service nginx restart

 

If you made a configuration on the local machine, you have to make a host file entry by executing the following command.

 

sudo nano /etc/hosts  

 

Add the following entry to this file.

127.0.0.1 odoo.example.com 

 

After completing the above configuration, you can access the Odoo server by hitting “odoo.example.com” in any browser.

 

Check the status of the nginx server configured successfully or not by executing the below command.

 

sudo nginx -t   

 

If you are facing an issue in configuration, then you check the Nginx server error and access the log below given path in your system.

 

/var/log/nginx/odoo.example.access.log 

 

/var/log/nginx/odoo.example.error.log   

 

Now, you can see that the Odoo server is running over the “http”. But what if we need to run our Odoo server over a more secure channel i.e. “https”? For that, please follow the below prompts.

Step- 5: SSL Configuration with Nginx

Make ssl directory under /etc/nginx/

 

cd /etc/nginx 

 

mkdir ssl    

 

cd ssl 

 

Now, we have to create a certificate using OpenSSL by executing the following command.

 

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/odoo.example.com.key -out /etc/nginx/ssl/odoo.example.com.crt

 

After creating the certificate, update the Nginx config file with the below content.

 

server {    

    listen 80;   

    server_name odoo.example.com;   

    return 301 https://$host$request_uri;   

    }   

server {   

    listen 443 ssl;   

    server_name odoo.example.com;   

    ssl_certificate /etc/nginx/ssl/odoo.example.com.crt;   

    ssl_certificate_key  /etc/nginx/ssl/odoo.example.com.key;   

    access_log /var/log/nginx/odoo.example.access.log;   

    error_log /var/log/nginx/odoo.example.error.log;   

    location / {   

        proxy_pass http://127.0.0.1:8069;   

    } 

  } 

 

After updating the config file, restart the Nginx server using the below command.

sudo service nginx restart

 

To check whether nginx runs successfully or not, please execute the below command.

sudo nginx -t

 

Now, open any browser and hit the URL “https://odoo.example.com”. You’ll be able to access your URL over a secure channel i.e. HTTPS. Even if you hit the URL using HTTP, it will be automatically redirected to https.

Conclusion

Configuring Nginx as a reverse proxy for Odoo offers several benefits, including performance, flexibility, scalability, and privacy. Although Odoo comes with a built-in web server it is recommended to have a reverse proxy. Nginx as a reverse proxy is configured with Odoo that acts as an intermediary between the client and the Odoo server.

 

We are an official Odoo Partner and Odoo development service provider. If you have any further queries or need assistance with Odoo, we are just a phone call away. Please feel free to get in touch with us.

contact-us Request a callback WhatsApp