First draft of using Caddy as the reverse proxy

This commit is contained in:
Davide 2024-09-18 11:58:12 +02:00
parent 5ce1ddec1a
commit 203e51c576
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# https://caddyserver.com/docs/metrics
:9000 {
metrics
}
subdomain.domain.tld {
reverse_proxy ${local_ip}:${port}
# https://caddyserver.com/docs/caddyfile/directives/basic_auth
basic_auth {
Username hashed_password
}
log
}

View File

@ -0,0 +1,59 @@
---
x-logging:
&default-logging
driver: syslog
options:
# This requires two files in /etc/rsyslog.d
# https://www.loggly.com/use-cases/docker-syslog-logging-and-troubleshooting/
tag: "container_name/{{.Name}}"
labels: "${hostname}"
syslog-facility: # cron, local7, etc.
# Can be removed if not needed
x-opt-values:
&volume-opt
driver_opts: &options
type: "nfs"
o: "addr=${IP},rw"
services:
caddy:
image: lucaslorentz/caddy-docker-proxy:ci-alpine
container_name: caddy
restart: unless-stopped
labels:
caddy.email: ${CADDY_EMAIL}
environment:
# $ docker network create caddy
CADDY_INGRESS_NETWORKS: caddy
CADDY_DOCKER_CADDYFILE_PATH: "/etc/caddy/Caddyfile"
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- caddy_data:/data
- ./Caddyfile:/etc/caddy/Caddyfile
networks:
- caddy
ulimits:
nofile: 65535
logging: *default-logging
networks:
caddy:
external: true
volumes:
caddy_data: {}
# What if I want to use the x-opt-values:
# acme:
# <<: *volume-opt
# driver_opts:
# <<: *options
# device: ":/mnt/path/nginx-proxy/acme"
# o: "new_opts"
# type: "new_type"
#
# 'o' and 'type' can be redifined again or left at default