Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Caddy v2.1.0

Quentin McGaw edited this page Jun 29, 2020 · 1 revision

Setup

Run the container with the default Caddyfile

docker run -d --name caddy -p 80:8080/tcp -p 443:8443/tcp qmcgaw/caddy-scratch:v2.1.0

Caddyfile

By default, this runs using the repository Caddyfile:

{
    admin 0.0.0.0:2019
    http_port 8080
    https_port 8443
}

To use your own Caddyfile:

  1. Create a directory mkdir caddydir

  2. Create a Caddyfile with the content you would like, in caddydir/Caddyfile. Note that at the top of your Caddyfile, there should be at least the following global block:

    {
        http_port 8080
        https_port 8443
    }
  3. Change the ownership and permission to match the Docker container

    chown -R 1000 caddydir
    chmod -R 700 caddydir

    If you are on Windows, you may skip this step.

  4. Assuming your current file path is /yourpath, run the container with:

    docker run -d --name caddy -p 80:8080/tcp -p 443:8443/tcp \
        -v /yourpath/caddydir:/caddydir qmcgaw/caddy-scratch:v2.1.0

Docker-compose

You can also run the container with docker-compose up -d and using this docker-compose.yml:

version: "3.7"
services:
  caddy:
    image: qmcgaw/caddy-scratch:v2.1.0
    container_name: caddy
    volumes:
      - ./caddydir:/caddydir
    environment:
      - TZ=
    network_mode: bridge
    ports:
      - 80:8080/tcp
      - 443:8443/tcp
      #- 2019:2019/tcp
    restart: always

Log times

If log times are not correct, it's because you need to set your timezone in the TZ environment variable. For example, add -e TZ=America/Montreal to your Docker run command.

Update

Update the docker image with docker pull qmcgaw/caddy-scratch:v2.1.0. You can also use the :latest Docker tag to get more regular updates.

Caddy API

To access the Caddy API, you need:

  • your Caddyfile to contain admin 0.0.0.0:2019 at the top global block (as is in the default Caddyfile)
  • (eventually) have port 2019 published by adding -p 2019:2019/tcp to your Docker run command

Try it with

curl localhost:2019/config/

Plugins

Note that many Caddy plugins do not work yet on Caddy v2.1.0.

You need Git installed.

If you want to have for example the github.com/caddyserver/ntlm-transport plugin, build the image with

docker build -t qmcgaw/caddy:v2.1.0 \
    --build-arg PLUGINS=github.com/caddyserver/ntlm-transport \
    https://github.com/qdm12/caddy-scratch.git#v2.1.0
Clone this wiki locally