CrowdSec (detection only) and staged custom-Caddy plumbing
- crowdsec stack on lava reading Caddy's access log (logs/ subpath only), collections caddy, http-cve, base-http-scenarios, appsec-virtual-patching; AppSec listener on :7422; allowlist for lava, Tailscale, the server - caddy_custom switch (image + plugin directives), staged by caddy_crowdsec_enforce / caddy_appsec / caddy_ratelimit; all off, so the rendered config is unchanged in effect - (protect) on every site, (ratelimit_login) on login paths, both empty until enabled; caddy recreated when compose.yml or .env changes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8aad8132b6
commit
48a4e48b84
13 files changed
+261
-1
No files matched your search
@@ -132,6 +132,17 @@ user (`vault_aws_dns`). It also deletes the records listed under
|
|||||||
- `ufw-docker` makes UFW govern container ports. Only Caddy (80/443) and
|
- `ufw-docker` makes UFW govern container ports. Only Caddy (80/443) and
|
||||||
Gitea SSH (host port 222) are allowed in from the internet.
|
Gitea SSH (host port 222) are allowed in from the internet.
|
||||||
- Admin UIs (Dockge, Syncthing, Cronmaster, Apprise, CouchDB) bind to the Tailscale IP only.
|
- Admin UIs (Dockge, Syncthing, Cronmaster, Apprise, CouchDB) bind to the Tailscale IP only.
|
||||||
|
- Caddy writes a JSON access log to `/data/logs/access.log` (volume
|
||||||
|
`caddy_caddy_data`). CrowdSec (infrastructure, tag `crowdsec`) reads it.
|
||||||
|
- Custom Caddy: `caddy_custom` in `infrastructure.yml` switches between stock
|
||||||
|
`caddy:2-alpine` and the image from repo `phil/caddy-custom` (CrowdSec
|
||||||
|
bouncer, AppSec, rate limiting; rebuilt daily, rolled out by dockcheck).
|
||||||
|
`caddy_crowdsec_enforce`, `caddy_appsec` and `caddy_ratelimit` stage the
|
||||||
|
features; `caddy_custom: false` rolls all of it back in one deploy.
|
||||||
|
- Unban an IP: `docker exec crowdsec cscli decisions delete --ip <ip>` (SSH
|
||||||
|
over Tailscale never goes through Caddy).
|
||||||
|
- Tinyauth (`auth.`) puts a Pocket ID login (group `admins`) in front of
|
||||||
|
Baikal's `/admin` and the Changedetection UI via the `(sso)` snippet.
|
||||||
|
|
||||||
### SSO (Pocket ID)
|
### SSO (Pocket ID)
|
||||||
Pocket ID (`id.thesatelliteoflove.com`) replaced Authentik on 2026-10-31.
|
Pocket ID (`id.thesatelliteoflove.com`) replaced Authentik on 2026-10-31.
|
||||||
|
|||||||
@@ -33,3 +33,23 @@ notifications:
|
|||||||
appriseapi_endpoint: "http://apprise:8000/notify/apprise"
|
appriseapi_endpoint: "http://apprise:8000/notify/apprise"
|
||||||
# Pocket ID group allowed through Tinyauth to admin pages.
|
# Pocket ID group allowed through Tinyauth to admin pages.
|
||||||
tinyauth_admin_group: admins
|
tinyauth_admin_group: admins
|
||||||
|
|
||||||
|
# Custom Caddy (repo phil/caddy-custom: CrowdSec bouncer + AppSec + rate
|
||||||
|
# limiting, rebuilt daily, rolled out by dockcheck).
|
||||||
|
# caddy_custom: false = stock caddy:2-alpine and no plugin directives in the
|
||||||
|
# Caddyfile; set it back to false to roll everything back in one deploy.
|
||||||
|
# The other flags stage the rollout and only matter when caddy_custom is on.
|
||||||
|
caddy_custom: false
|
||||||
|
caddy_custom_image: "{{ subdomains.git }}/phil/caddy"
|
||||||
|
caddy_custom_tag: "2" # pin to "<ver>-<fingerprint>" to hold a build
|
||||||
|
caddy_image: "{{ (caddy_custom_image ~ ':' ~ caddy_custom_tag) if caddy_custom else 'caddy:2-alpine' }}"
|
||||||
|
caddy_crowdsec_enforce: false # block IPs CrowdSec has banned
|
||||||
|
caddy_appsec: false # AppSec virtual patching on each request
|
||||||
|
caddy_ratelimit: false # per-IP limits on login POSTs
|
||||||
|
|
||||||
|
# Never banned by CrowdSec, never rate limited.
|
||||||
|
crowdsec_allowlist:
|
||||||
|
- "{{ docker.subnet }}" # containers hairpinning through Caddy
|
||||||
|
- "100.64.0.0/10" # Tailscale IPv4
|
||||||
|
- "fd7a:115c:a1e0::/48" # Tailscale IPv6
|
||||||
|
- "{{ network.netcup_ip }}" # the server itself
|
||||||
@@ -6,6 +6,13 @@
|
|||||||
- compose.yml
|
- compose.yml
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart crowdsec
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: /opt/stacks/crowdsec
|
||||||
|
files:
|
||||||
|
- compose.yml
|
||||||
|
state: restarted
|
||||||
|
|
||||||
- name: restart obsidian-livesync
|
- name: restart obsidian-livesync
|
||||||
community.docker.docker_compose_v2:
|
community.docker.docker_compose_v2:
|
||||||
project_src: /opt/stacks/obsidian-livesync
|
project_src: /opt/stacks/obsidian-livesync
|
||||||
|
|||||||
@@ -14,12 +14,24 @@
|
|||||||
group: docker
|
group: docker
|
||||||
notify: restart caddy
|
notify: restart caddy
|
||||||
|
|
||||||
|
- name: template caddy .env (CrowdSec bouncer key)
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: caddy-env.j2
|
||||||
|
dest: /opt/stacks/caddy/.env
|
||||||
|
owner: root
|
||||||
|
mode: '0640'
|
||||||
|
group: docker
|
||||||
|
diff: false
|
||||||
|
when: caddy_custom
|
||||||
|
register: caddy_env
|
||||||
|
|
||||||
- name: template caddy compose file
|
- name: template caddy compose file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: caddy-compose.yml.j2
|
src: caddy-compose.yml.j2
|
||||||
dest: /opt/stacks/caddy/compose.yml
|
dest: /opt/stacks/caddy/compose.yml
|
||||||
owner: root
|
owner: root
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
|
register: caddy_compose
|
||||||
|
|
||||||
- name: deploy caddy stack
|
- name: deploy caddy stack
|
||||||
community.docker.docker_compose_v2:
|
community.docker.docker_compose_v2:
|
||||||
@@ -28,6 +40,16 @@
|
|||||||
files:
|
files:
|
||||||
- compose.yml
|
- compose.yml
|
||||||
|
|
||||||
|
# recreate: never (above) keeps the running container, so a new image or env
|
||||||
|
# (caddy_custom on/off, a pinned tag) only applies through this task.
|
||||||
|
- name: recreate caddy when its compose file or .env changed
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: /opt/stacks/caddy
|
||||||
|
recreate: always
|
||||||
|
files:
|
||||||
|
- compose.yml
|
||||||
|
when: caddy_compose.changed or (caddy_env.changed | default(false))
|
||||||
|
|
||||||
# Lets public traffic through to Caddy. Re-adds the rule if Caddy's IP changed.
|
# Lets public traffic through to Caddy. Re-adds the rule if Caddy's IP changed.
|
||||||
- name: allow public traffic to caddy
|
- name: allow public traffic to caddy
|
||||||
ansible.builtin.command: /usr/local/bin/ufw-docker.sh allow caddy-caddy-1 {{ item }}
|
ansible.builtin.command: /usr/local/bin/ufw-docker.sh allow caddy-caddy-1 {{ item }}
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# CrowdSec next to Caddy. Unban: docker exec crowdsec cscli decisions delete --ip <ip>
|
||||||
|
- name: make crowdsec directories
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
loop:
|
||||||
|
- /opt/stacks/crowdsec
|
||||||
|
- /opt/stacks/crowdsec/acquis.d
|
||||||
|
|
||||||
|
- name: Template out the crowdsec compose file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: crowdsec-compose.yml.j2
|
||||||
|
dest: /opt/stacks/crowdsec/compose.yml
|
||||||
|
owner: root
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Template out the crowdsec .env file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: crowdsec-env.j2
|
||||||
|
dest: /opt/stacks/crowdsec/.env
|
||||||
|
owner: root
|
||||||
|
mode: '0640'
|
||||||
|
group: docker
|
||||||
|
diff: false # contains the bouncer key
|
||||||
|
|
||||||
|
- name: Template out the crowdsec acquisition files
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "crowdsec-acquis-{{ item }}.yaml.j2"
|
||||||
|
dest: "/opt/stacks/crowdsec/acquis.d/{{ item }}.yaml"
|
||||||
|
owner: root
|
||||||
|
mode: '0644'
|
||||||
|
loop: [caddy, appsec]
|
||||||
|
notify: restart crowdsec
|
||||||
|
|
||||||
|
- name: deploy crowdsec stack
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: /opt/stacks/crowdsec
|
||||||
|
files:
|
||||||
|
- compose.yml
|
||||||
|
|
||||||
|
- name: wait for the crowdsec local API
|
||||||
|
ansible.builtin.command: docker exec crowdsec cscli lapi status
|
||||||
|
register: crowdsec_lapi
|
||||||
|
retries: 20
|
||||||
|
delay: 3
|
||||||
|
until: crowdsec_lapi.rc == 0
|
||||||
|
changed_when: false
|
||||||
|
when: not ansible_check_mode
|
||||||
|
|
||||||
|
# Our own networks are never banned (centralized allowlist, CrowdSec >= 1.6.8)
|
||||||
|
- name: read the crowdsec allowlist
|
||||||
|
ansible.builtin.command: docker exec crowdsec cscli allowlists inspect trusted -o json
|
||||||
|
register: crowdsec_allowlist_current
|
||||||
|
failed_when: false
|
||||||
|
changed_when: false
|
||||||
|
when: not ansible_check_mode
|
||||||
|
|
||||||
|
- name: create the crowdsec allowlist
|
||||||
|
ansible.builtin.command: docker exec crowdsec cscli allowlists create trusted -d "own networks (ansible)"
|
||||||
|
when: not ansible_check_mode and crowdsec_allowlist_current.rc != 0
|
||||||
|
|
||||||
|
- name: add missing entries to the crowdsec allowlist
|
||||||
|
ansible.builtin.command: >-
|
||||||
|
docker exec crowdsec cscli allowlists add trusted {{ item }} -d ansible
|
||||||
|
loop: "{{ crowdsec_allowlist }}"
|
||||||
|
when: >-
|
||||||
|
not ansible_check_mode and
|
||||||
|
(crowdsec_allowlist_current.rc != 0 or item not in crowdsec_allowlist_current.stdout)
|
||||||
@@ -9,6 +9,10 @@
|
|||||||
import_tasks: pocketid.yml
|
import_tasks: pocketid.yml
|
||||||
tags: pocketid
|
tags: pocketid
|
||||||
|
|
||||||
|
- name: Install crowdsec
|
||||||
|
import_tasks: crowdsec.yml
|
||||||
|
tags: crowdsec
|
||||||
|
|
||||||
- name: Install tinyauth
|
- name: Install tinyauth
|
||||||
import_tasks: tinyauth.yml
|
import_tasks: tinyauth.yml
|
||||||
tags: tinyauth
|
tags: tinyauth
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
{% if caddy_custom %}
|
||||||
|
# Plugins come from the custom image (repo phil/caddy-custom).
|
||||||
|
{
|
||||||
|
order crowdsec first
|
||||||
|
order appsec after crowdsec
|
||||||
|
crowdsec {
|
||||||
|
api_url http://crowdsec:8080
|
||||||
|
api_key {$CROWDSEC_API_KEY}
|
||||||
|
ticker_interval 15s
|
||||||
|
appsec_url http://crowdsec:7422
|
||||||
|
# Inspect at most 1 MiB of a body (uploads, registry pushes).
|
||||||
|
appsec_max_body_bytes 1048576
|
||||||
|
# CrowdSec being down must not take every site down.
|
||||||
|
appsec_fail_open
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
# Tell browsers to always use HTTPS for each site for a year. No
|
# Tell browsers to always use HTTPS for each site for a year. No
|
||||||
# includeSubDomains, so hosts not served here are unaffected.
|
# includeSubDomains, so hosts not served here are unaffected.
|
||||||
# defer: replace any HSTS header an app sends itself, so there's only one.
|
# defer: replace any HSTS header an app sends itself, so there's only one.
|
||||||
@@ -56,6 +74,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import hsts
|
import hsts
|
||||||
import security_headers
|
import security_headers
|
||||||
|
import protect
|
||||||
header {
|
header {
|
||||||
Content-Security-Policy "base-uri 'self'; object-src 'none'; frame-ancestors 'self'; form-action 'self'"
|
Content-Security-Policy "base-uri 'self'; object-src 'none'; frame-ancestors 'self'; form-action 'self'"
|
||||||
X-Frame-Options SAMEORIGIN
|
X-Frame-Options SAMEORIGIN
|
||||||
@@ -73,28 +92,65 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# CrowdSec, imported by every site (via site/static_site). Empty unless the
|
||||||
|
# custom image is on and the stage is enabled (caddy_crowdsec_enforce,
|
||||||
|
# caddy_appsec). AppSec skips bulk binary traffic: registry and git pushes.
|
||||||
|
(protect) {
|
||||||
|
{% if caddy_custom and caddy_crowdsec_enforce %}
|
||||||
|
crowdsec
|
||||||
|
{% endif %}
|
||||||
|
{% if caddy_custom and caddy_appsec %}
|
||||||
|
@appsec not path /v2/* /api/packages/* */git-upload-pack */git-receive-pack */info/refs
|
||||||
|
appsec @appsec
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Per-IP limit on login/token POSTs: import ratelimit_login <zone> <paths...>
|
||||||
|
# Zone names must be unique per site. Our own networks are exempt.
|
||||||
|
(ratelimit_login) {
|
||||||
|
{% if caddy_custom and caddy_ratelimit %}
|
||||||
|
rate_limit {
|
||||||
|
zone {args[0]} {
|
||||||
|
match {
|
||||||
|
method POST
|
||||||
|
path {args[1:]}
|
||||||
|
not remote_ip {{ crowdsec_allowlist | join(' ') }}
|
||||||
|
}
|
||||||
|
key {client_ip}
|
||||||
|
events 10
|
||||||
|
window 1m
|
||||||
|
}
|
||||||
|
log_key
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
|
||||||
# Every proxied site: log, HSTS and the shared headers.
|
# Every proxied site: log, HSTS and the shared headers.
|
||||||
(site) {
|
(site) {
|
||||||
import logging
|
import logging
|
||||||
import hsts
|
import hsts
|
||||||
import security_headers
|
import security_headers
|
||||||
|
import protect
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ subdomains.pocketid }} {
|
{{ subdomains.pocketid }} {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login pocketid_login /api/webauthn/login/* /api/one-time-access-token* /api/one-time-access-email*
|
||||||
reverse_proxy pocket-id:1411
|
reverse_proxy pocket-id:1411
|
||||||
}
|
}
|
||||||
|
|
||||||
{{ subdomains.tinyauth }} {
|
{{ subdomains.tinyauth }} {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login tinyauth_login /api/oauth/*
|
||||||
reverse_proxy tinyauth:3000
|
reverse_proxy tinyauth:3000
|
||||||
}
|
}
|
||||||
|
|
||||||
paper.thesatelliteoflove.com {
|
paper.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login paperless_login /accounts/login/ /api/token/
|
||||||
reverse_proxy paperlessngx-webserver-1:8000
|
reverse_proxy paperlessngx-webserver-1:8000
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,24 +168,28 @@ cal.thesatelliteoflove.com {
|
|||||||
{{ subdomains.books }} {
|
{{ subdomains.books }} {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login kavita_login /api/Account/login /api/Account/forgot-password /api/Plugin/authenticate
|
||||||
reverse_proxy kavita:5000
|
reverse_proxy kavita:5000
|
||||||
}
|
}
|
||||||
|
|
||||||
audio.thesatelliteoflove.com {
|
audio.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login abs_login /login /auth/refresh
|
||||||
reverse_proxy audiobookshelf-audiobookshelf-1:80
|
reverse_proxy audiobookshelf-audiobookshelf-1:80
|
||||||
}
|
}
|
||||||
|
|
||||||
loclog.thesatelliteoflove.com {
|
loclog.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login dawarich_login /users/sign_in
|
||||||
reverse_proxy dawarich_app:3000
|
reverse_proxy dawarich_app:3000
|
||||||
}
|
}
|
||||||
|
|
||||||
watcher.thesatelliteoflove.com {
|
watcher.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login cd_login /login
|
||||||
# UI needs Pocket ID; the API (own key) stays reachable for scripts.
|
# UI needs Pocket ID; the API (own key) stays reachable for scripts.
|
||||||
@ui not path /api/*
|
@ui not path /api/*
|
||||||
import sso @ui
|
import sso @ui
|
||||||
@@ -139,12 +199,14 @@ watcher.thesatelliteoflove.com {
|
|||||||
snippets.thesatelliteoflove.com {
|
snippets.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login bytestash_login /api/auth/login /api/auth/register
|
||||||
reverse_proxy bytestash:5000
|
reverse_proxy bytestash:5000
|
||||||
}
|
}
|
||||||
|
|
||||||
git.thesatelliteoflove.com {
|
git.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login gitea_login /user/login /user/sign_up /user/forgot_password /user/two_factor* /login/oauth/access_token
|
||||||
reverse_proxy gitea:3000
|
reverse_proxy gitea:3000
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,18 +233,21 @@ thesatelliteoflove.com {
|
|||||||
bookmarks.thesatelliteoflove.com {
|
bookmarks.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login karakeep_login /api/auth/callback/credentials /api/auth/signin/*
|
||||||
reverse_proxy hoarder-web-1:3000
|
reverse_proxy hoarder-web-1:3000
|
||||||
}
|
}
|
||||||
|
|
||||||
social.thesatelliteoflove.com {
|
social.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login gts_login /auth/sign_in /oauth/token /auth/2fa*
|
||||||
reverse_proxy gotosocial:8080
|
reverse_proxy gotosocial:8080
|
||||||
}
|
}
|
||||||
|
|
||||||
models.thesatelliteoflove.com {
|
models.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login manyfold_login /users/sign_in
|
||||||
reverse_proxy manyfold-app-1:3214
|
reverse_proxy manyfold-app-1:3214
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +255,7 @@ models.thesatelliteoflove.com {
|
|||||||
gotify.thesatelliteoflove.com {
|
gotify.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login gotify_login /client /user
|
||||||
reverse_proxy gotify:80
|
reverse_proxy gotify:80
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +283,7 @@ pdg.thesatelliteoflove.com {
|
|||||||
starpunk.thesatelliteoflove.com {
|
starpunk.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login starpunk_login /auth/login /auth/authorize /auth/token
|
||||||
# MCP endpoint and its OAuth protected resource metadata (StarPunk v2.15.0)
|
# MCP endpoint and its OAuth protected resource metadata (StarPunk v2.15.0)
|
||||||
@mcp path /mcp /mcp/* /.well-known/oauth-protected-resource /.well-known/oauth-protected-resource/*
|
@mcp path /mcp /mcp/* /.well-known/oauth-protected-resource /.well-known/oauth-protected-resource/*
|
||||||
handle @mcp {
|
handle @mcp {
|
||||||
@@ -247,6 +314,7 @@ forms.nerder.land {
|
|||||||
listmonk.nerder.land {
|
listmonk.nerder.land {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login listmonk_login /admin/login /subscription/form /api/public/subscription
|
||||||
reverse_proxy listmonk:9000
|
reverse_proxy listmonk:9000
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +326,7 @@ repaircafe.nerder.land {
|
|||||||
gokapi.thesatelliteoflove.com {
|
gokapi.thesatelliteoflove.com {
|
||||||
import site
|
import site
|
||||||
import no_framing
|
import no_framing
|
||||||
|
import ratelimit_login gokapi_login /login
|
||||||
reverse_proxy gokapi:53842
|
reverse_proxy gokapi:53842
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
services:
|
services:
|
||||||
caddy:
|
caddy:
|
||||||
image: caddy:2-alpine
|
image: {{ caddy_image }}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
- "443:443/udp"
|
- "443:443/udp"
|
||||||
|
{% if caddy_custom %}
|
||||||
|
env_file: .env # CROWDSEC_API_KEY
|
||||||
|
{% endif %}
|
||||||
volumes:
|
volumes:
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||||
- ./site:/srv
|
- ./site:/srv
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
CROWDSEC_API_KEY={{ vault_crowdsec.bouncer_key }}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# AppSec endpoint for the Caddy bouncer; reachable only on lava.
|
||||||
|
source: appsec
|
||||||
|
name: caddy-appsec
|
||||||
|
listen_addr: 0.0.0.0:7422
|
||||||
|
appsec_configs:
|
||||||
|
- crowdsecurity/appsec-default
|
||||||
|
labels:
|
||||||
|
type: appsec
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Caddy's JSON access log (exact name, so rolled access-*.log files aren't re-read)
|
||||||
|
filenames:
|
||||||
|
- /var/log/caddy/access.log
|
||||||
|
labels:
|
||||||
|
type: caddy
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# CrowdSec: reads Caddy's JSON access log, decides which IPs to ban, and
|
||||||
|
# serves those decisions (LAPI :8080) and AppSec checks (:7422) to Caddy over
|
||||||
|
# lava. Nothing is published to the host.
|
||||||
|
services:
|
||||||
|
crowdsec:
|
||||||
|
image: crowdsecurity/crowdsec:{{ crowdsec_version | default('latest') }}
|
||||||
|
container_name: crowdsec
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file: .env # BOUNCER_KEY_caddy
|
||||||
|
environment:
|
||||||
|
COLLECTIONS: >-
|
||||||
|
crowdsecurity/caddy crowdsecurity/http-cve crowdsecurity/base-http-scenarios
|
||||||
|
crowdsecurity/appsec-virtual-patching
|
||||||
|
TZ: Etc/UTC
|
||||||
|
volumes:
|
||||||
|
- crowdsec_config:/etc/crowdsec
|
||||||
|
- crowdsec_data:/var/lib/crowdsec/data
|
||||||
|
- ./acquis.d:/etc/crowdsec/acquis.d:ro
|
||||||
|
# Only the logs/ folder of Caddy's data volume; its TLS keys stay out.
|
||||||
|
- type: volume
|
||||||
|
source: caddy_data
|
||||||
|
target: /var/log/caddy
|
||||||
|
read_only: true
|
||||||
|
volume:
|
||||||
|
subpath: logs
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
labels:
|
||||||
|
mag37.dockcheck.update: true
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
crowdsec_config:
|
||||||
|
crowdsec_data:
|
||||||
|
caddy_data:
|
||||||
|
external: true
|
||||||
|
name: caddy_caddy_data
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
external: true
|
||||||
|
name: {{ docker.network_name }}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
BOUNCER_KEY_caddy={{ vault_crowdsec.bouncer_key }}
|
||||||
Reference in new issue
Block a user