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
@@ -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
|
||||
# includeSubDomains, so hosts not served here are unaffected.
|
||||
# defer: replace any HSTS header an app sends itself, so there's only one.
|
||||
@@ -56,6 +74,7 @@
|
||||
import logging
|
||||
import hsts
|
||||
import security_headers
|
||||
import protect
|
||||
header {
|
||||
Content-Security-Policy "base-uri 'self'; object-src 'none'; frame-ancestors 'self'; form-action 'self'"
|
||||
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.
|
||||
(site) {
|
||||
import logging
|
||||
import hsts
|
||||
import security_headers
|
||||
import protect
|
||||
}
|
||||
|
||||
{{ subdomains.pocketid }} {
|
||||
import site
|
||||
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
|
||||
}
|
||||
|
||||
{{ subdomains.tinyauth }} {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login tinyauth_login /api/oauth/*
|
||||
reverse_proxy tinyauth:3000
|
||||
}
|
||||
|
||||
paper.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login paperless_login /accounts/login/ /api/token/
|
||||
reverse_proxy paperlessngx-webserver-1:8000
|
||||
}
|
||||
|
||||
@@ -112,24 +168,28 @@ cal.thesatelliteoflove.com {
|
||||
{{ subdomains.books }} {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login kavita_login /api/Account/login /api/Account/forgot-password /api/Plugin/authenticate
|
||||
reverse_proxy kavita:5000
|
||||
}
|
||||
|
||||
audio.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login abs_login /login /auth/refresh
|
||||
reverse_proxy audiobookshelf-audiobookshelf-1:80
|
||||
}
|
||||
|
||||
loclog.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login dawarich_login /users/sign_in
|
||||
reverse_proxy dawarich_app:3000
|
||||
}
|
||||
|
||||
watcher.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login cd_login /login
|
||||
# UI needs Pocket ID; the API (own key) stays reachable for scripts.
|
||||
@ui not path /api/*
|
||||
import sso @ui
|
||||
@@ -139,12 +199,14 @@ watcher.thesatelliteoflove.com {
|
||||
snippets.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login bytestash_login /api/auth/login /api/auth/register
|
||||
reverse_proxy bytestash:5000
|
||||
}
|
||||
|
||||
git.thesatelliteoflove.com {
|
||||
import site
|
||||
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
|
||||
}
|
||||
|
||||
@@ -171,18 +233,21 @@ thesatelliteoflove.com {
|
||||
bookmarks.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login karakeep_login /api/auth/callback/credentials /api/auth/signin/*
|
||||
reverse_proxy hoarder-web-1:3000
|
||||
}
|
||||
|
||||
social.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login gts_login /auth/sign_in /oauth/token /auth/2fa*
|
||||
reverse_proxy gotosocial:8080
|
||||
}
|
||||
|
||||
models.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login manyfold_login /users/sign_in
|
||||
reverse_proxy manyfold-app-1:3214
|
||||
}
|
||||
|
||||
@@ -190,6 +255,7 @@ models.thesatelliteoflove.com {
|
||||
gotify.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login gotify_login /client /user
|
||||
reverse_proxy gotify:80
|
||||
}
|
||||
|
||||
@@ -217,6 +283,7 @@ pdg.thesatelliteoflove.com {
|
||||
starpunk.thesatelliteoflove.com {
|
||||
import site
|
||||
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 path /mcp /mcp/* /.well-known/oauth-protected-resource /.well-known/oauth-protected-resource/*
|
||||
handle @mcp {
|
||||
@@ -247,6 +314,7 @@ forms.nerder.land {
|
||||
listmonk.nerder.land {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login listmonk_login /admin/login /subscription/form /api/public/subscription
|
||||
reverse_proxy listmonk:9000
|
||||
}
|
||||
|
||||
@@ -258,6 +326,7 @@ repaircafe.nerder.land {
|
||||
gokapi.thesatelliteoflove.com {
|
||||
import site
|
||||
import no_framing
|
||||
import ratelimit_login gokapi_login /login
|
||||
reverse_proxy gokapi:53842
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user