How to setup Nginx for Odoo?

How to setup Nginx for Odoo?

NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

How to improve the performance of odoo using Nginx?

As Nginx is a well known high performance load balancer. By installing and configuring Nginx in server, we can boost the odoo performance. Below are the steps to install Nginx.

Step 1: Stop the Apache server.

This is better to stop the apache server while installing nginx to avoid any errors.

sudo service apache2 stop

Step 2: Install Nginx.

sudo apt-get install nginx

Step 3: Update the Nginx Config file.

Edit the Nginx main configuration file with a text editor and insert the following block after the line which specifies Nginx document root location.

sudo vim /etc/nginx/sites-enabled/default

Add the below code to specify the location:

location / {
proxy_pass http://127.0.0.1:8069;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

Comment the existing location code as below:

#location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#       try_files $uri $uri/ =404;
#}

nginx-odoo

Now test the configuration with the command nginx -t

If it returns no error, then restart the Nginx.

Step 4: Restart Nginx.

Just run getenforcecommand to check if Selinux in enabled on your machine or not. If it is enabled, disable it.

To completely disable Selinux, open /etc/selinux/config file with a text editor and set the line SELINUX to disabled.

sudo systemctl restart nginx

OR

sudo service nginx restart

Step 5: Restart Apache.

sudo service apache2 restart

One thought on “How to setup Nginx for Odoo?

Leave a Reply

Your email address will not be published. Required fields are marked *