X

About Us

We Provide Digital Transformation Solutions Centered Around Your Needs. At the core of our ethos is a commitment to delivering cutting-edge solutions that empower businesses and drive success in the digital era.

Contact Info

  • Ahmedabad, India
  • info@planupsolution.com
  • Week Days: 09.00 to 18.00
  • +91 9875021819

How to Configure Odoo with Nginx as a Reverse Proxy and SSL on Ubuntu

PlanUp Solution > Blog > Blog > How to Configure Odoo with Nginx as a Reverse Proxy and SSL on Ubuntu

How to Configure Odoo with Nginx as a Reverse Proxy and SSL on Ubuntu

Configure SSL and Nginx

Configuring Odoo with Nginx as a reverse proxy involves setting up Nginx to act as an intermediary between the client and the Odoo application. Typically, Odoo runs on port 8069, and we access the server by adding “:8069” to the domain. To simplify access and make the server function like a standard website, we need to configure Nginx with Odoo. Additionally, securing the setup with SSL is essential for protecting data and enhancing security.

Steps to Configure Nginx for Odoo

Step 1: Update Server Packages

First, update the existing Ubuntu packages and upgrade them to the latest versions.

sudo apt update
sudo apt upgrade -y

Step 2: Install Nginx

Install Nginx on the server.

sudo apt install nginx -y

After the installation, check the status of the Nginx service.

service nginx status

If Nginx is not running, start the service.

sudo service nginx start

Step 3: Configure Nginx

Navigate to the Nginx directory and create a configuration file for Odoo.

cd /etc/nginx/sites-available
sudo nano odoo.conf

Copy and paste the following content into the file, replacing IP_ADDRESS_OR_DOMAIN_NAME with your server’s IP address or domain name.

upstream odoo {
    server 127.0.0.1:8069;
}
upstream odoochat {
    server 127.0.0.1:8072;
}
server {
    listen 80;
    server_name IP_ADDRESS_OR_DOMAIN_NAME;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    # Add Headers for Odoo proxy mode
    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;

    # Log settings
    access_log /var/log/nginx/odoo.access.log;
    error_log /var/log/nginx/odoo.error.log;

    # Redirect requests to Odoo backend server
    location / {
        proxy_redirect off;
        proxy_pass http://odoo;
    }
    location /longpolling {
        proxy_pass http://odoochat;
    }

    # Enable Gzip compression
    gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
    gzip on;

    client_body_in_file_only clean;
    client_body_buffer_size 32K;
    client_max_body_size 500M;
    sendfile on;
    send_timeout 600s;
    keepalive_timeout 300;
}

Save the file and create a symbolic link in the sites-enabled directory.

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

Test the Nginx configuration for syntax errors.

sudo nginx -t

If the test is successful, restart Nginx.

sudo service nginx restart

Step 4: Update Odoo Configuration

Enable proxy mode in Odoo’s configuration file.

sudo nano /etc/odoo-server.conf

Add the following line:

proxy_mode=True

Restart the Odoo server.

sudo service odoo-server restart

Configuring SSL with Let’s Encrypt

Step 1: Install Certbot

Certbot is a tool to obtain and manage SSL certificates from Let’s Encrypt.

sudo apt install certbot python3-certbot-nginx -y

Step 2: Obtain an SSL Certificate

Run Certbot to obtain and configure an SSL certificate.

sudo certbot --nginx -d your_domain -d www.your_domain

Follow the prompts to complete the certificate issuance and configuration.

Step 3: Auto-Renew SSL Certificate

Set up a cron job to automatically renew the SSL certificate.

sudo crontab -e

Add the following line:

0 0,12 * * * /usr/bin/certbot renew --quiet

Configuring SSL with a Purchased Certificate

Step 1: Obtain Your SSL Certificate

After purchasing an SSL certificate, you will receive the certificate files from your provider. These typically include the primary certificate, a CA bundle, and a private key.

Step 2: Upload SSL Files to Server

Upload the SSL certificate files to your server, typically in the /etc/ssl/certs directory.

Step 3: Configure Nginx to Use SSL

Edit your Nginx configuration to use the SSL certificate.

sudo nano /etc/nginx/sites-available/odoo.conf

Update the server block to include SSL settings:

server {
    listen 80;
    server_name IP_ADDRESS_OR_DOMAIN_NAME;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name IP_ADDRESS_OR_DOMAIN_NAME;

    ssl_certificate /etc/ssl/certs/your_certificate.crt;
    ssl_certificate_key /etc/ssl/private/your_private_key.key;
    ssl_trusted_certificate /etc/ssl/certs/your_ca_bundle.crt;

    proxy_read_timeout 720s;
    proxy_connect_timeout 720s;
    proxy_send_timeout 720s;

    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;

    access_log /var/log/nginx/odoo.access.log;
    error_log /var/log/nginx/odoo.error.log;

    location / {
        proxy_redirect off;
        proxy_pass http://odoo;
    }
    location /longpolling {
        proxy_pass http://odoochat;
    }

    gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
    gzip on;

    client_body_in_file_only clean;
    client_body_buffer_size 32K;
    client_max_body_size 500M;
    sendfile on;
    send_timeout 600s;
    keepalive_timeout 300;
}

Save the file and restart Nginx.

sudo service nginx restart

Conclusion

Configuring Nginx as a reverse proxy for Odoo not only simplifies access but also enhances security and performance. By adding SSL, either through Let’s Encrypt or a purchased certificate, you ensure secure data transmission and a more professional setup. For more details on Odoo configurations and services, explore our Odoo CRM and expert Odoo hosting and installation pages.

For further assistance, feel free to contact us at PlanUp Solutions.

Feel free to reach out anytime at info@planupsolution.com or on WhatsApp: +91 9875021819.

Leave A Comment

All fields marked with an asterisk (*) are required