chore: refactor caddy folder structure

This commit is contained in:
2025-07-09 00:08:57 -03:00
parent 10b0f122e1
commit 925cf377c7
5 changed files with 44 additions and 39 deletions

View File

@@ -7,7 +7,7 @@
# Logging # Logging
log { log {
level DEBUG level INFO
format console format console
} }
@@ -19,40 +19,5 @@
} }
# Example: Static file server # Import all site configurations from sites-enabled directory
# static.example.com { import /etc/caddy/sites-enabled/*.Caddyfile
# root * /srv/static/test
# file_server
# }
# Example: Reverse Proxy for service running in docker container (must be under caddy_net)
# api.example.com {
# coraza_waf {
# directives `
# Include /etc/caddy/coraza.conf
# `
# }
#
# reverse_proxy * http://{CONTAINER_NAME}:{CONTAINER_PORT}
# }
# Example: Bypassing WAF for given API path
# NEEDED FOR PROMETHEUS
# api.example2.com {
# basic_auth {
# agala {$PROMETHEUS_PASSWORD}
# }
#
# @waf {
# not path /api/v1/*
# }
#
# handle @waf {
# coraza_waf {
# directives `
# Include /etc/caddy/coraza.conf
# `
# }
# }
# reverse_proxy * http://prometheus:9090
# }

View File

@@ -6,7 +6,7 @@
# only to start with, because that minimises the chances of post-installation # only to start with, because that minimises the chances of post-installation
# disruption. # disruption.
# #
SecRuleEngine DetectionOnly SecRuleEngine On
# -- Request body handling --------------------------------------------------- # -- Request body handling ---------------------------------------------------

View File

@@ -0,0 +1,19 @@
# Example configurations for different use cases
# Remove this file and create your own site-specific Caddyfiles
# Example: Static file server
# static.example.com {
# root * /srv/static/YOUR_APP_FOLDER
# file_server
# }
# Example: Reverse Proxy for service running in docker container (must be under caddy_net)
# api.example.com {
# coraza_waf {
# directives `
# Include /etc/caddy/coraza.conf
# `
# }
#
# reverse_proxy * http://{CONTAINER_NAME}:{CONTAINER_PORT}
# }

View File

@@ -0,0 +1,20 @@
# Prometheus monitoring endpoint
# Bypasses WAF for API endpoints since Prometheus scraping doesn't need WAF protection
prometheus.example.com {
basic_auth {
agala {$PROMETHEUS_PASSWORD}
}
@waf {
not path /api/v1/*
}
handle @waf {
coraza_waf {
directives `
Include /etc/caddy/coraza.conf
`
}
}
reverse_proxy * http://prometheus:9090
}

View File

@@ -25,6 +25,7 @@ services:
volumes: volumes:
- ../../deploy/static:/srv/static # Your static files location - ../../deploy/static:/srv/static # Your static files location
- ./caddy/Caddyfile:/etc/caddy/Caddyfile - ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ./caddy/sites-enabled:/etc/caddy/sites-enabled
- ./caddy/coraza/coraza.conf:/etc/caddy/coraza.conf - ./caddy/coraza/coraza.conf:/etc/caddy/coraza.conf
- ./caddy/logs:/var/log/caddy - ./caddy/logs:/var/log/caddy
- caddy_data:/data - caddy_data:/data