feat: Initial commit.
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.env
|
||||
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
||||
ARG CADDY_VERSION=2
|
||||
|
||||
FROM docker.io/caddy:${CADDY_VERSION}-builder-alpine AS builder
|
||||
|
||||
RUN xcaddy build \
|
||||
--with github.com/caddy-dns/cloudflare \
|
||||
--with github.com/mholt/caddy-l4 \
|
||||
--with github.com/caddyserver/transform-encoder \
|
||||
--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
|
||||
9
LICENSE
Normal file
9
LICENSE
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 homelab
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
11
README.md
Normal file
11
README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# caddy
|
||||
|
||||
This is the primary entrypoint / reverse proxy used for services that run under the `ductcalc.pro`
|
||||
domain.
|
||||
|
||||
## Usage
|
||||
|
||||
1. clone this repository to the host
|
||||
1. copy the `example.env` to `.env`
|
||||
1. update the environment variables
|
||||
1. start the stack
|
||||
32
caddy/Caddyfile
Normal file
32
caddy/Caddyfile
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
email {env.ACME_EMAIL}
|
||||
servers {
|
||||
client_ip_headers X-Forwarded-For
|
||||
trusted_proxies static private_ranges
|
||||
trusted_proxies_strict
|
||||
}
|
||||
order crowdsec before respond
|
||||
crowdsec {
|
||||
api_url http://crowdsec:8080
|
||||
api_key {$CROWDSEC_API_KEY}
|
||||
ticker_interval 15s
|
||||
}
|
||||
log {
|
||||
level INFO
|
||||
output file /var/log/caddy/access.log
|
||||
roll_size 30MiB
|
||||
roll_keep 5
|
||||
}
|
||||
tls {
|
||||
dns cloudflare {env.CF_AUTH_TOKEN}
|
||||
resolvers 1.1.1.1
|
||||
}
|
||||
}
|
||||
|
||||
ductcalc.pro {
|
||||
tls
|
||||
log
|
||||
crowdsec
|
||||
reverse_proxy http://ductcalc:8080
|
||||
}
|
||||
|
||||
59
compose.yaml
Normal file
59
compose.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
services:
|
||||
caddy:
|
||||
build:
|
||||
context: .
|
||||
target: caddy
|
||||
container_name: caddy
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- CLOUDFLARE_EMAIL=${CF_EMAIL}
|
||||
- CLOUDFLARE_API_TOKEN=${CF_AUTH_TOKEN}
|
||||
- ACME_AGREE=true
|
||||
- CROWDSEC_API_KEY=${CROWDSEC_API_KEY}
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
- "443:443/udp"
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
volumes:
|
||||
- ./caddy:/etc/caddy
|
||||
- caddy_data:/data
|
||||
- caddy_config:/config
|
||||
- caddy_logs:/var/log/caddy
|
||||
networks:
|
||||
- proxy
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
|
||||
crowdsec:
|
||||
image: docker.io/crowdsecurity/crowdsec:latest
|
||||
container_name: crowdsec
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- GID=1000
|
||||
- COLLECTIONS=crowdsecurity/linux crowdsecurity/caddy crowdsecurity/http-cve crowdsecurity/whitelist-good-actors
|
||||
- BOUNCER_KEY_CADDY=${CROWDSEC_API_KEY}
|
||||
volumes:
|
||||
- crowdsec_db:/var/lib/crowdsec/data/
|
||||
- ./crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml
|
||||
- caddy_logs:/var/log/caddy:ro
|
||||
networks:
|
||||
- proxy
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
depends_on:
|
||||
- caddy
|
||||
|
||||
volumes:
|
||||
caddy_data: {}
|
||||
caddy_config: {}
|
||||
caddy_logs: {}
|
||||
crowdsec_db: {}
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
|
||||
5
crowdsec/acquis.yaml
Normal file
5
crowdsec/acquis.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
filenames:
|
||||
- /var/log/caddy/*.log
|
||||
labels:
|
||||
type: caddy
|
||||
|
||||
4
example.env
Normal file
4
example.env
Normal file
@@ -0,0 +1,4 @@
|
||||
ACME_EMAIL="acme@example.com"
|
||||
CF_AUTH_TOKEN="secret-token"
|
||||
CF_EMAIL="cloudflare@example.com"
|
||||
CROWDSEC_API_KEY="CHANGEME"
|
||||
Reference in New Issue
Block a user