Compute Engine Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud. In this tutorial you are going to learn how to install and setup Odoo with Nginx reverse proxy and connect it with PostgreSQL in Cloud SQL.

This setup is tested on Google Cloud Platform with the following Infrastructure.

  • Compute Engine VM Instance: 3.75 GB RAM, 10 GB SSD
  • Cloud SQL: 614 MB RAM, PostgreSQL

Choose Best Hosting for your Business

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

Prerequisites

With the above-completed prerequisites I assume you have your instance up and running, DNS configured and Cloud SQL is authorized to allow connections from the VM Instance.

Step 1: Server Setup

Once your Ubuntu server is updated and upgraded to latest packages you can start installing Odoo.

Step 2: Install Wkhtmltopdf

Wkhtmltopdf is package that is used to render HTML to PDF and other image formats. If you are using Odoo to print PDF reports you should install wkhtmltopdf tool. The recommended version for Odoo is 0.12.5. This is not included in the default Ubuntu 18.04 repository.

So we shall download the package and install it.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

Step 3: Install Odoo 13

Now you can install Odoo 13 by adding the repository to your Ubuntu server.

wget -O - https://nightly.odoo.com/odoo.key | sudo apt-key add -
echo "deb http://nightly.odoo.com/13.0/nightly/deb/ ./" | sudo tee /etc/apt/sources.list.d/odoo.list

Update the apt cache and proceed install Odoo13.

sudo apt update
sudo apt install odoo

Once the installation is complete Odoo is started automatically as a service.

To make sure Odoo is running you can check the status using the following command.

sudo service odoo status
Output
● odoo.service - Odoo Open Source ERP and CRM
    Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
    Active: active (running) since Wed 2019-10-23 10:29:38 UTC; 10min ago
  Main PID: 8387 (odoo)
     Tasks: 6 (limit: 4395)
    CGroup: /system.slice/odoo.service
            └─8387 /usr/bin/python3 /usr/bin/odoo --config /etc/odoo/odoo.conf --logfile /var/log/odoo/odoo-server.log
 Oct 23 10:29:38 odoo systemd[1]: Started Odoo Open Source ERP and CRM.

This indicates Odoo is started and running successfully.

Now you can enable Odoo service to start on system boot.

sudo systemctl enable --now odoo

Step 4: Configure Cloud SQL – PostgreSQL

Now you can configure Odoo to use remote database like Cloud SQL or Amazon RDS.

sudo nano /etc/odoo/odoo.conf

Replace the highlighted values corresponding to your Cloud SQL values.

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = CloudSQL_Public_IP
db_port = False
db_user = CloudSQL_user
db_password = CloudSQL_user_password
;addons_path = /usr/lib/python3/dist-packages/odoo/addons

Restart Odoo.

sudo service odoo restart

Step 5: Install Nginx

Install Nginx using the followng command.

sudo apt install nginx

Remove default Nginx configurations.

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

Step 6: Configure Nginx Reverse proxy for Odoo

Create a new Nginx configuration for Odoo in the sites-available directory.

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

Copy and paste the following configuration, ensure that you change the server_name to match your domain name.

upstream odooserver {
     server 127.0.0.1:8069;
}

server {
     listen 80;
     server_name domainname.com;

     access_log /var/log/nginx/odoo_access.log;
     error_log /var/log/nginx/odoo_error.log;

     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;

     location / {
        proxy_redirect off;
        proxy_pass http://odooserver;
     }

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

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

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

To enable this newly created website configuration, symlink the file that you just created into the sites-enabled directory.

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

Check your configuration and restart Nginx for the changes to take effect.

sudo nginx -t
sudo service nginx restart

Step 7: Install and configure SSL for Odoo

HTTPS
HTTPS is a protocol for secure communication between a server (instance) and a client (web browser). Due to the introduction of Let’s Encrypt, which provides free SSL certificates, HTTPS are adopted by everyone and also provides trust to your audiences.

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install python-certbot-nginx

Now we have installed Certbot by Let’s Encrypt for Ubuntu 18.04, run this command to receive your certificates.

sudo certbot --nginx certonly

Enter your email and agree to the terms and conditions, then you will receive the list of domains you need to generate SSL certificate.

To select all domains simply hit Enter

The Certbot client will automatically generate the new certificate for your domain. Now we need to update the Nginx config.

Redirect HTTP Traffic to HTTPS

Open your site’s Nginx configuration file add replace everything with the following. Replacing the file path with the one you received when obtaining the SSL certificate. The ssl_certificate directive should point to your fullchain.pem file, and the ssl_certificate_key directive should point to your privkey.pem file.

 upstream odooserver {
     server 127.0.0.1:8069;
 }

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

     server_name domainname.com www.domainname.com;

     return 301 https://domainname.com$request_uri;
 }

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

     server_name www.domainname.com;

     ssl_certificate /etc/letsencrypt/live/domainname.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/domainname.com/privkey.pem;

     return 301 https://domainname.com$request_uri;
 }

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

     server_name domainname.com;

     ssl_certificate /etc/letsencrypt/live/domainname.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/domainname.com/privkey.pem;

     access_log /var/log/nginx/odoo_access.log;
     error_log /var/log/nginx/odoo_error.log;

     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;

     location / {
        proxy_redirect off;
        proxy_pass http://odooserver;
     }

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

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

Hit CTRL+X followed by Y to save the changes.

Check your configuration and restart Nginx for the changes to take effect.

sudo nginx -t
sudo service nginx restart

Renewing SSL Certificate

Certificates provided by Let’s Encrypt are valid for 90 days only, so you need to renew them often. Now you set up a cronjob to check for the certificate which is due to expire in next 30 days and renew it automatically.

sudo crontab -e

Add this line at the end of the file

0 0,12 * * * certbot renew >/dev/null 2>&1

Hit CTRL+X followed by Y to save the changes.

This cronjob will attempt to check for renewing the certificate twice daily.

Step 8: 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 Nginx in Google Cloud and secure it with Let’s Encrypt.

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

14 Comments

    • Cloudbooklet Reply

      Ah, yes. Thank you. But this is just a guide to install Odoo

    • I believe anyone that’s landed here already has a clue what Odoo is and how to set it up on your localhost…

      • But I liked your tutorial, I was skimming looking for how to create a custom dashboard in Odoo and stumbled upon this. Nice read. I’ll raise up any queries if any…

  1. This is a great write-up, but I seem to be something missing with defining the Log files.

    The step to check Nginx “sudo nginx -t” is returning a “unknown log “error_log”

    Googling the issue leads me to believe I need to have an HTML section that defines the parameters of what the log files record. I don’t see where that is defined in the first config setup, nor the second.

  2. After install and configure with Nginx with a subdomain while open server using subdomain it works well. But while try to login it gives ” refused to connect.”

    Can you have any idea what is wrong?

  3. Hi, at the step 7 “sudo certbot –nginx certonly” it’s stuck on “Waiting for verification…” for a few seconds and return errors, here is the log:

    Obtaining a new certificate
    Performing the following challenges:
    http-01 challenge for xxxxxx.com
    Waiting for verification…
    Cleaning up challenges
    Failed authorization procedure. xxxxxx.com (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://xxxxxx.com/.well-known/acme-challenge/mhLe5XHIY9vrdJIaykz0_NTDC6LfivyINnHTBfFf7HU: Connection reset by peer

    IMPORTANT NOTES:
    – The following errors were reported by the server:

    Domain: xxxxxx.com
    Type: connection
    Detail: Fetching
    http://xxxxxx.com/.well-known/acme-challenge/mhLe5XHIY9vrdJIaykz0_NTDC6LfivyINnHTBfFf7HU:
    Connection reset by peer

    To fix these errors, please make sure that your domain name was
    entered correctly and the DNS A/AAAA record(s) for that domain
    contain(s) the right IP address. Additionally, please check that
    your computer has a publicly routable IP address and that no
    firewalls are preventing the server from communicating with the
    client. If you’re using the webroot plugin, you should also verify
    that you are serving files from the webroot path you provided.

    I am using Godaddy domain service and tried setting up either Name Server to Google name server (I had created a DNS zone as in another of your guides) and DNS A Record point the instance IP record but seem not better.

    Any idea? thanks

    • Hi, thanks for using Cloudbooklet. Please make sure, your domain name is pointed to the correct IP address and the propagation is completed, and also make sure you specified the correct domain name in the Nginx server blocks.

    • Thanks for your reply.
      – I think my domain correctly pointed to the GC Instance IP address, I entered all 4 name servers address from Google cloud DNS to GoDaddy my domain Customer name servers.
      When I tried pinging to the domain, it returned the correct IP with smooth responses
      – “specify the correct In the Nginx server blocks”:
      At the step Step 6, file “/etc/nginx/sites-available/odoo.conf” I did enter my correct domain I configure in the Google cloud DNS, just rechecked and it’s


      “server {
      listen 80;
      server_name MyDomain.com;

      I am not using Google domain, is it possible that Godaddy is the cause?

      Still being in stuck at step 7 for 2 days: sudo certbot –nginx certonly . And cannot start my Odoo server for work 😐
      Please help/advise! Thanks

  4. Hi there. Is anyone else having issues with uploading files through Nginx? I have my config file setup just as explained above and SSL is working great, but I can’t seem to upload files through HTTPS. I can upload without issue directly connecting to port 8069 though.

    I have found some articles that reference needing to add something like “add_header X-Frame-Options SAMEORIGIN;” (without saying where it should go) or that it’s a file size issue. But the solution is just vague enough that i’m having a hard time getting this resolved.

    Support thread Referenced;
    https://www.odoo.com/pt_BR/forum/ajuda-1/question/unable-to-attach-files-in-odoo-when-using-https-via-nginx-121288

    Once I get this fixed, we are ready to go live, but this is a show stopper for us and our Odoo developer doesn’t want to touch anything that isn’t hosted on Odoo.com.

    • Hi Devin,
      The add_header directive can be added after the location directive inside the server block.
      For client_max_body_size directive you can add this inside the http or server or location blocks.

  5. Could you make guide to install Odoo 13 in Google Kubernetes Engine? and what is the different between install odoo 13 in Google Cloud Compute Engine with Google Kubernetes Engine?

Write A Comment

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