Docker: Caddy Webserver

Quick and Dirty snippet to start Caddy Webserver

Quick and Dirty snippet to start Caddy Webserver

This container can be used as simple Webserver or Reverse Proxy - it includes automatically optaining a SSL certificate and securing the sites here.

prerequisites:

  • installed linux system with docker-compose
  • have a domain and A / AAAA record pointed to the linux system
  • running in /services/caddy
  • adjust the values in Caddyfile to your services

Caddyfile

#sample file for a reverse proxy 
example.com {
        encode zstd gzip
        reverse_proxy http://172.17.0.1:8080
}

docker-compose.yml

version: "3.7"
services:
  caddy:
    image: caddy
    container_name: caddy
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /services/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /services/caddy/data:/data
      - /services/caddy/config:/config

After you've created both files you can start the container with

docker-compose up -d