AWS

Install Odoo using Docker, Nginx on Ubuntu 20.04 – AWS

Install Odoo using Docker Compose, Nginx, SSL on Ubuntu 20.04 – AWS. In this tutorial you are going to learn how to install and setup Odoo using Docker and Docker Compose and configure Nginx and Let’s Encrypt SSL and connect it with PostgreSQL in Amazon RDS. Installing Odoo using Docker Compose is the easiest way compared to install manually.

Odoo is a management self hosted software to run a business with a top notch user experience. The applications within Odoo are perfectly integrated with each other, allowing you to fully automate your business processes easily.

Choose Best Hosting for your Business

PlatformReviewsPricing
Siteground★★★★★$3.95
Kinsta – Google Cloud★★★★★$30

Prerequisites

  1. A running EC2 Instance. Learn how to create an AWS EC2 instance. Please use Ubuntu 20.04
  2. Assigned a Elastic IP to your EC2 Instance.
  3. Setup Amazon RDS and connect it with EC2 Instance (Please choose PostgreSQL 12 for Engine).
  4. Setup and configure Route 53 and point your domain to AWS.
  5. Successful SSH connection to your EC2 Instance.
  6. Install Docker on Ubuntu 20.04
  7. Install Docker Compose on Ubuntu 20.04.

Please make sure you have completed all the above mentioned steps

  • Ubuntu 20.04 on EC2
  • PostgreSQL 12 on Amazon RDS
  • Domain pointed to the EC2 Elastic IP address
  • Docker installed and configured
  • Docker Compose installed and configured

Step 1: Create a project directory

SSH to the EC2 instance and start by creating a new project directory named odoo-project. You can also name it whatever you need.

sudo mkdir odoo-project

Step 2: Create Docker Compose YAML file

Now navigate inside the project directory and create a new docker-compose.yml file with the following configuration.

cd odoo-project
sudo nano docker-compose.yml

Paste the following configuration.

version: '3'
services:
    odoo:
        container_name: odoo
        image: odoo:latest
        volumes:
            - ./addons-extra:/mnt/extra-addons
            - ./etc/odoo/config:/etc/odoo
            - odoo-web-data:/var/lib/odoo
        ports:
            - "8069:8069"
        nginx:
            container_name: nginx
            image: nginx:latest
            restart: unless-stopped
        ports:
            - 80:80
            - 443:443
        volumes:
            - ./nginx/conf:/etc/nginx/conf.d
            - ./certbot/conf:/etc/nginx/ssl
            - ./certbot/data:/var/www/html
        certbot:
            container_name: certbot
            image: certbot/certbot:latest
            command: certonly --webroot --webroot-path=/var/www/html -- email [email protected] --agree-tos --no-eff-email -d domain.com -d www.domain.com
        volumes:
            - ./certbot/conf:/etc/letsencrypt
            - ./certbot/logs:/var/log/letsencrypt
            - ./certbot/data:/var/www/html
volumes:
    odoo-web-data:

Hit CTRL + X followed by Y and Enter to save the file and exit.

Here are the configuration details.

  • version: Compose file version which is compatible with the Docker Engine. You can check compatibility here.
  • services: here we have 3 services named odoonginx and certbot.
  • image: We use latest Odoo, Nginx and Certbot images available in Docker hub.
  • volumes:
    • nginx/conf: here we will place the Nginx configuration file to be synced with the default Nginx conf.d folder inside the container.
    • cedtbot/conf: this is where we will receive the SSL certificate and this will be synced with the folder we wish to inside the container.
    • ports: configure the container to listen upon the listed ports.
    • command: the command used to receive the SSL certificate.

Step 3: Create Odoo Configuration

Now you can use custom Odoo configuration inside the directory as mentioned in the yml file in the Oddo service.

sudo mkdir -p etc/odoo/config

Create a new file named odoo.conf

sudo nano /etc/odoo/odoo.conf

Replace the highlighted values corresponding to your RDS values.

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = RDS_ENDPOINT
db_user = RDS_user
db_password = RDS_user_password

Step 4: Configure aNginx

Now you can create he default configuration file inside the directory as mentioned in the yml file in the Nginx service.

sudo mkdir -p nginx/config

Create a new file named default.conf

sudo nano /nginx/conf/default.conf

Paste the following configuration and replace the appropriate values with your domain name.

server {
    listen [::]:80;
    listen 80;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /var/www/html;
    }

    location / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }

    location ~* /web/static/ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }
}

Step 5: Deploy Oddo with Docker

Now you can make the deployment using the following command.

Start the containers using the following command, you will receive the SSL certificates once the containers are started.

docker-compose up -d

Once all containers are started you will see additional directories for SSL will be created alongside your docker-compose.yml file.

The directory certbot holds all the files related to your SSL certificates.

To view the containers you can execute the following command.

docker-compose ps

Step 6: Configure SSL for Odoo in Docker

As you have received the Let’s Encrypt SSL certificate you can configure HTTPS and setup redirection to HTTPS.

Edit the default.conf and make the following changes.

sudo nano nginx/conf/default.conf
server {
    listen [::]:80;
    listen 80;

    server_name domain.com;

    return 301 https://www.domain.com$request_uri;
}

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name domain.com;

    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

    return 301 https://www.domain.com$request_uri;
}
server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name domain.com;

    ssl_certificate /etc/nginx/ssl/live/domain.com/fullchain.pem;
    ssl_certificate_key /etc/nginx/ssl/live/domain.com/privkey.pem;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /var/www/html;
    }

    location / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }

    location ~* /web/static/ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
        proxy_pass http://odoo:8069;
    }
}

Now restart the Nginx service to load the new configurations.

docker-compose restart nginx

Step 7: Setup Odoo

Now you can visit your domain name on your web browser. You will see the page similar to the one below. Here you can create the database and admin user for your Odoo.

Odoo Setup

Fill in all appropriate values and click create database. Now Odoo will be ready to use.

Odoo Dashboard

Conclusion

Learn a complete walk through of the Odoo Sales Application with tips on using advanced configurations.

Now you have learned how to install Odoo 13 on your Ubuntu server with Docker Compose, Nginx snd secure it with Let’s Encrypt on AWS.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Cloudbooklet builds a large collection of Linux based guides and tutorials on Cloud platforms like Google Cloud, AWS, Azure, DigitalOcean and more

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

If you find this helpful? Support me!
Buy me a coffee Donation Please buy me a coffee