Skip to content

geekyharsh05/typesense-self-hosted-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Self-Hosted Typesense with Docker Compose and Caddy

A minimal, production-ready setup to self-host Typesense behind Caddy with automatic HTTPS, plus the Typesense Dashboard.

Reference guide: Now You Know How to Self-Host Typesense Using Docker and Caddy — The Easy Way

What you get

  • Typesense API (internal port 8108)
  • Typesense Dashboard UI (internal port 80)
  • Caddy reverse proxy with automatic TLS for both services

Prerequisites

  • A VPS or server with Docker and the Docker Compose plugin
  • DNS A records for your domains pointing to the server IP
    • dashboard.yourdomain.com
    • typesense-api.yourdomain.com

Files in this repo

  • compose.yml — defines typesense, dashboard, and caddy services
  • Caddyfile — routes public domains to the correct containers
  • .env — environment variables (you create this)

1) Create your .env file

Create a .env file in the project root:

TYPESENSE_API_KEY=YOUR_KEY
PUBLIC_PATH=/dashboard
TYPESENSE_HOST=typesense
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http

Notes:

  • TYPESENSE_API_KEY is the admin key used by Typesense and the dashboard.
  • You can generate a new admin key after startup via the Typesense API if desired.

2) Configure DNS

Create A records for your domains:

  • dashboard.yourdomain.com → your server IP
  • typesense-api.yourdomain.com → your server IP

3) Update the Caddyfile

Edit Caddyfile and replace the example domains with yours:

# Route traffic for the dashboard
dashboard.yourdomain.com {
    reverse_proxy dashboard:80
}

# Route traffic for the Typesense API
typesense-api.yourdomain.com {
    reverse_proxy typesense:8108
}

4) Start the stack

From the project root:

docker compose -f compose.yml up -d

Verify containers:

docker ps

You should see typesense, dashboard, and caddy running.

5) Access and connect

  • Dashboard: https://dashboard.yourdomain.com
  • Typesense health: https://typesense-api.yourdomain.com/health (expect { "ok": true })

In the dashboard “Connect” screen, use:

  • Host: typesense-api.yourdomain.com
  • Port: 443
  • Protocol: https
  • API Key: value from TYPESENSE_API_KEY
  • Path: leave empty

Generate an admin key (optional)

If you want to rotate or create a new admin key after startup, run (from your host):

curl 'http://localhost:8108/keys' \
  -X POST \
  -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{"description":"Admin key.","actions":["*"],"collections":["*"]}'

Data persistence

  • Typesense data is stored in ./typesense-data (mounted to /data in the container).
  • The dashboard uses the dashboard_data volume.
  • Caddy state/config uses caddy_data and caddy_config volumes.

Common operations

  • View logs:
    • docker logs typesense
    • docker logs caddy
    • docker logs typesense-self-hosted-example-dashboard-1 (container name may vary)
  • Restart services:
    • docker compose -f compose.yml restart
  • Update images:
    • docker compose -f compose.yml pull && docker compose -f compose.yml up -d

Security tips

  • Keep your admin TYPESENSE_API_KEY secret and rotate periodically.
  • Use firewall rules to only expose ports 80/443 publicly.
  • Regularly back up ./typesense-data.

About

A minimal, production-ready setup to self-host Typesense behind Caddy with automatic HTTPS, plus the Typesense Dashboard.

Topics

Resources

Stars

Watchers

Forks