diff --git a/caddy/Caddyfile b/caddy/Caddyfile index 7e7770e..a9ea132 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,13 +1,23 @@ -{$CADDY_BASE_HOST} { - encode zstd gzip - reverse_proxy http://frontend:3000 - handle_path /api/* { - reverse_proxy http://backend:3000 +{ + crowdsec { + api_url {$CROWDSEC_API_URL} + api_key {$CROWDSEC_API_KEY} } - handle_path /profileImages/* { - rewrite * /sorvor{path} - reverse_proxy http://minio:9000 +} +{$CADDY_BASE_HOST} { + route { + crowdsec + encode zstd gzip + reverse_proxy http://frontend:3000 + handle_path /api/* { + reverse_proxy http://backend:3000 + } + handle_path /profileImages/* { + rewrite * /sorvor{path} + reverse_proxy http://minio:9000 + + } } log { output file /var/log/caddy/access.log diff --git a/caddy/Dockerfile b/caddy/Dockerfile new file mode 100644 index 0000000..9a21526 --- /dev/null +++ b/caddy/Dockerfile @@ -0,0 +1,14 @@ +ARG CADDY_VERSION=2 + +FROM caddy:${CADDY_VERSION}-builder-alpine AS builder + +RUN xcaddy build \ + --with github.com/mholt/caddy-l4 \ + --with github.com/hslatman/caddy-crowdsec-bouncer/http@main \ + --with github.com/hslatman/caddy-crowdsec-bouncer/layer4@main + +FROM caddy:${CADDY_VERSION} AS caddy + +WORKDIR / + +COPY --from=builder /usr/bin/caddy /usr/bin/caddy diff --git a/compose.yml b/compose.yml index a07c09c..c5ae5b4 100644 --- a/compose.yml +++ b/compose.yml @@ -32,7 +32,9 @@ services: env_file: - .env caddy: - image: caddy + build: + context: ./caddy/ + target: caddy restart: unless-stopped env_file: - .env @@ -64,7 +66,6 @@ services: - crowdsec-db:/var/lib/crowdsec/data/ - crowdsec-config:/etc/crowdsec/ - ./crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml - - ./crowdsec/acquis-test.yaml:/etc/crowdsec/acquis-test.yaml volumes: crowdsec-db: