Knowledgebase

Question About Servers

How to Setup Odoo with Nginx as a Reverse Proxy in Ubuntu Print

  • 1

This article explains how to set up Nginx as a reverse proxy for your Odoo installation in Ubuntu

Pre-requisites

  • Ubuntu VPS with 2GB RAM or more.
  • Python3
  • An Odoo installation with access via the IP address and the Odoo port.
  • The desired domain name to map to your Odoo instance.
  • SSH access to the VPS with root privileges.

Step 1: Prepare your Odoo Instance

You can follow one of these guides to install Odoo into your VPS until you can display the following page by entering the server's IP address and the Odoo port into the web browser in the following format:

http://IP_Address:Odoo_port

Step 2: Connect to the Server via SSH.

In order to perform any commands on your remote server, you will need to SSH into your VPS. Follow this guide to access your server via SSH.

Step 3: Install Nginx Web Server

You need a web server to be able to access your Odoo instance using your domain name instead of the server's IP address. To install Nginx, run the following commands.

Update the server:

sudo apt update && sudo apt upgrade

Install Nginx web server.

sudo apt -y install nginx

Enable Nginx to start on server boot.

sudo systemctl enable nginx

Step 4: Create a Nginx Server Block for your Domain

Nginx Server Blocks allow you to run more than one website on a single machine. With Server Blocks, you can specify the site document root (the directory which contains the website files). In this instance, let's assume your domain is "thisdomain.com". To create a server block for the domain, run the following command (be sure to replace "thisdomain.com" with your actual domain):

nano /etc/nginx/sites-available/thisdomain.com

This command will open up the configuration file. Enter the configuration information as below.

upstream odoo {
   server 127.0.0.1:8069;
}

server {
   listen 80 default;
   server_name thisdomain.com;

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

   proxy_buffers 16 64k;
   proxy_buffer_size 128k;

   location / {
      proxy_pass http://odoo;
      proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
      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 https;
   }

   location ~* /web/static/ {
      proxy_cache_valid 200 60m;
      proxy_buffering on;
      expires 864000;
      proxy_pass http://odoo;
   }
}

Save the file and exit the editor.

Step 5: Restart the Nginx Web Server

Restart the web server for the changes you've made above to take effect. Use the following command to restart Nginx.

sudo systemctl restart nginx

Congratulations! You can now be able to access your Odoo instance by typing your domain and in the web browser. This example works with the following address.

http://thisdomain.com

Was this answer helpful?

« Back

Enterprise-Grade Hardware

  • Samsung
  • Juniper
  • Western Digital
  • Supermicro
  • LSI
  • Intel
  • R1Soft Backups
  • cPanel
  • MySQL
  • Parallels
  • HP Partner