Home » Blog » How to self-host Chatwoot using Docker

How to self-host Chatwoot using Docker

Chatwoot is an open-source customer engagement suite that can be self-hosted. This guide will walk you through the steps to deploy Chatwoot using Docker.

What you need

You need an up-to-date version of Docker and Docker Compose, installed on your web-server (e.g., running on Ubuntu 20.04) and a domain, pointed to your server’s IP address.

  • Docker installed on your server
  • A domain name pointed to your server’s IP address

Note: We’ll use Hetzner Cloud as our hosting provider, but you can use any other provider as well.

Deploy Chatwoot using docker-compose

Step 1: Install Docker on your web-server or virtual machine

Simply copy and paste the code below into your cmd/terminal and follow the instructions.

Bash
apt-get update
apt-get upgrade
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
apt install docker-compose-plugin

Step 2: Download the required files to run Chatwoot

Next, get the .env and docker-compose.yaml files.

Bash
wget -O .env https://raw.githubusercontent.com/chatwoot/chatwoot/develop/.env.example
wget -O docker-compose.yaml https://raw.githubusercontent.com/chatwoot/chatwoot/develop/docker-compose.production.yaml

Step 3: Tweak the .env and docker-compose.yaml files to your liking

See the available environment variables of Chatwoot. Optionally, remove dependent services like Postgres and Redis in favor of managed services configured via variables.

  • .env: Update the redis and postgres passwords
  • docker-compose.yaml: Update the same postgres password
Bash
nano .env
nano docker-compose.yaml

Step 4: Run migrations to prepare the database

Run the migrations using Docker Compose.

Bash
docker compose run --rm rails bundle exec rails db:chatwoot_prepare

Step 5: Run Docker Compose

Start the service and keep it running.

Bash
docker compose up -d

Step 6: Configure Nginx

To access Chatwoot through your own domain, you need to configure Nginx to serve as a frontend proxy.

Bash
sudo apt-get install nginx
cd /etc/nginx/sites-enabled
nano yourdomain.com.conf

Step 7: Enter your domain

Change <yourdomain.com> for your domain.

Bash
server {
  server_name <yourdomain.com>;

  set $upstream 127.0.0.1:3000;

  underscores_in_headers on;
  location /.well-known {
    alias /var/www/ssl-proof/chatwoot/.well-known;
  }

  location / {
    proxy_pass_header Authorization;
    proxy_pass http://$upstream;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_http_version 1.1;
    proxy_set_header Connection “”;
    proxy_buffering off;

    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
  }
  listen 80;
}
code

Example using codecope.org:

Bash
server {
  server_name codecope.org; # Example

  set $upstream 127.0.0.1:3000;

  underscores_in_headers on;
  location /.well-known {
    alias /var/www/ssl-proof/chatwoot/.well-known;
  }

  location / {
    proxy_pass_header Authorization;
    proxy_pass http://$upstream;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_http_version 1.1;
    proxy_set_header Connection “”;
    proxy_buffering off;

    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
  }
  listen 80;
}

Step 8: Verify and reload Nginx config

Next, please verify and reload your Nginx config using the following prompt.

Bash
nginx -t
systemctl reload nginx

Step 9: Install a new SSL certificate

Run Let’s Encrypt to configure SSL certificate using Certbot. Replace yourdomain.com with your own domain.

Bash
apt  install certbot
apt-get install python3-certbot-nginx
mkdir -p /var/www/ssl-proof/chatwoot/.well-known
certbot --webroot -w /var/www/ssl-proof/chatwoot/ -d yourdomain.com -i nginx

Example using codecope.org:

Bash
apt  install certbot
apt-get install python3-certbot-nginx
mkdir -p /var/www/ssl-proof/chatwoot/.well-known
certbot --webroot -w /var/www/ssl-proof/chatwoot/ -d codecope.org -i nginx #Example

Congrats, you’re all set! ✨

FAQ

What is Chatwoot?

Chatwoot is an open-source customer engagement platform that provides features like live chat, email management, and social media integrations. It can be used as a help desk, customer support tool, or team collaboration platform.

Is Chatwoot free to use?

Yes, Chatwoot is open-source and free to self-host. There’s also a cloud version available with different pricing tiers for businesses that prefer a managed solution.

What are the system requirements for self-hosting Chatwoot?

Minimum requirements:
2GB RAM
1 CPU core
20GB storage
Docker or Ruby on Rails environment
PostgreSQL database

Comments

Leave a Reply

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