Compare commits

..

8 Commits

Author SHA1 Message Date
a3d5809db4 remove obsolete version 2025-03-09 17:49:53 +01:00
3203317ce0 move sample files because templates ignores them 2025-03-09 16:43:37 +01:00
4242612c8f add required networks 2025-03-09 16:14:12 +01:00
1d3f18fbb8 fix remove stack 2025-03-09 16:06:51 +01:00
d758a0bdde fix missing / for data volume 2023-06-10 22:02:36 +02:00
64563d9e40 fix missing / for conf volume 2023-06-10 21:28:17 +02:00
bf361bd587 inital setup 2023-06-10 21:09:01 +02:00
f3b17e69ff inital setup 2023-06-10 21:08:44 +02:00
7 changed files with 112 additions and 1 deletions

5
.env.sample Normal file
View File

@@ -0,0 +1,5 @@
TAG=
APIPORT=
BASEDIR=
EXTRANET=
INTRANET=

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
files/
.env

View File

@@ -1,2 +1,55 @@
# compose-caddy # Basic Caddy docker-compose config
- can be run on single node setup or in swarm
- recommend to set `replicas` on 2 or more if deploy in swarm
- default setup requires 2 external networks
- Services with exposed Ports should be in frontend network
- Services only accessable for caddy should be in backend network
- on single host:
- docker network create frontend
- docker network create backend
- on swarm:
- docker network create --scope=swarm --attachable -d overlay frontend
- docker network create --scope=swarm --attachable -d overlay backend
## howto
### single node
#### start container
```bash
docker compose up -d
```
#### stop container (and remove)
```bash
docker compose down
```
#### view logs
```bash
docker compose logs -f
```
#### reload config
```bash
docker compose restart
```
### swarm
#### start aka deploy
```bash
docker stack deploy -c docker-compose.yml caddy
```
#### stop stack
```bash
docker stack rm caddy
```
#### view logs
```bash
docker service logs caddy_caddy -f
```
#### reload config (no downtime if replica 2 or more)
```bash
docker service update caddy_caddy --force
```

33
docker-compose.yml Normal file
View File

@@ -0,0 +1,33 @@
# https://docs.docker.com/compose/compose-file/compose-file-v3/
---
services:
caddy:
image: caddy:${TAG:-alpine}
container_name: caddy
env_file: .env
restart: unless-stopped
deploy:
replicas: 1 # in swarm set min 2
placement:
max_replicas_per_node: 1
update_config:
parallelism: 1
delay: 10s
ports:
- 80:80
- 443:443
- ${APIPORT:-2019}:2019
volumes:
- ${BASEDIR:-./files}/conf/:/etc/caddy/
- ${BASEDIR:-./files}/data/:/data/
networks:
- frontend
- backend
networks:
frontend:
name: ${EXTRANET:-frontend}
external: true
backend:
name: ${INTRANET:-backend}
external: true

View File

@@ -0,0 +1,2 @@
import snippets/*
import pages/*

View File

@@ -0,0 +1,4 @@
http://example.com {
import auth "*"
respond "example.com here!"
}

View File

@@ -0,0 +1,12 @@
## generate pass hash (debian):
# sudo apt install apache2-utils
# htpasswd -bnBC 10 "" password | tr -d ':'
# user: test
# password: password
(auth) {
basicauth {args.0} {
test $2y$10$XSrHHXUlQZeRumAc9nl7QevDzKv9H5TXVtb6nxr0Gmrk6VogHWRVK
}
}