mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 01:38:14 -04:00
parent
92d3dd361b
commit
74dcebf20b
71
docs/docs/admin/environments/caddy.mdx
Normal file
71
docs/docs/admin/environments/caddy.mdx
Normal file
@ -0,0 +1,71 @@
|
||||
# Caddy
|
||||
|
||||
To use Anubis with Caddy, stick Anubis between Caddy and your backend. For example, consider this application setup:
|
||||
|
||||
```mermaid
|
||||
---
|
||||
title: Caddy with Anubis in the middle
|
||||
---
|
||||
|
||||
flowchart LR
|
||||
T(User Traffic)
|
||||
TCP(TCP 80/443)
|
||||
An(Anubis)
|
||||
B(Backend)
|
||||
Blocked
|
||||
|
||||
T --> TCP
|
||||
TCP --> |Traffic filtering| An
|
||||
An --> |Happy traffic| B
|
||||
An --> |Malicious traffic| Blocked
|
||||
```
|
||||
|
||||
Instead of your traffic going directly to your backend, it takes a detour through Anubis. Anubis filters out the "bad" traffic and passes the "good" traffic to the backend.
|
||||
|
||||
To set up Anubis with Docker compose and Caddy, start with a `docker-compose` configuration like this:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
caddy:
|
||||
image: caddy:2
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
- 443:443/udp
|
||||
volumes:
|
||||
- ./conf:/etc/caddy
|
||||
- caddy_config:/config
|
||||
- caddy_data:/data
|
||||
|
||||
anubis:
|
||||
image: ghcr.io/techarohq/anubis:latest
|
||||
pull_policy: always
|
||||
environment:
|
||||
BIND: ":3000"
|
||||
TARGET: http://httpdebug:3000
|
||||
|
||||
httpdebug:
|
||||
image: ghcr.io/xe/x/httpdebug
|
||||
pull_policy: always
|
||||
|
||||
volumes:
|
||||
caddy_data:
|
||||
caddy_config:
|
||||
```
|
||||
|
||||
And then put the following in `conf/Caddyfile`:
|
||||
|
||||
```Caddyfile
|
||||
# conf/Caddyfile
|
||||
|
||||
yourdomain.example.com {
|
||||
tls your@email.address
|
||||
|
||||
reverse_proxy http://anubis:3000 {
|
||||
header_up X-Real-Ip {remote_host}
|
||||
header_up X-Http-Version {http.request.proto}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you want to protect multiple services with Anubis, you will need to either start multiple instances of Anubis (Anubis requires less than 32 MB of ram on average) or set up a two-tier routing setup where TLS termination is done with one instance of Caddy and the actual routing to services is done with another instance of Caddy. See the [nginx](./nginx.mdx) or [Apache](./apache.mdx) documentation to get ideas on how you would do this.
|
16
test/caddy/Caddyfile
Normal file
16
test/caddy/Caddyfile
Normal file
@ -0,0 +1,16 @@
|
||||
:80 {
|
||||
reverse_proxy http://anubis:3000 {
|
||||
header_up X-Real-Ip {remote_host}
|
||||
header_up X-Http-Version {http.request.proto}
|
||||
}
|
||||
}
|
||||
|
||||
:443 {
|
||||
tls /etc/techaro/pki/caddy.local.cetacean.club/cert.pem /etc/techaro/pki/caddy.local.cetacean.club/key.pem
|
||||
|
||||
reverse_proxy http://anubis:3000 {
|
||||
header_up X-Real-Ip {remote_host}
|
||||
header_up X-Http-Version {http.request.proto}
|
||||
header_up X-Tls-Version {http.request.tls.version}
|
||||
}
|
||||
}
|
9
test/caddy/Dockerfile
Normal file
9
test/caddy/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
# FROM caddy:2.10.0-builder AS builder
|
||||
|
||||
# RUN xcaddy build \
|
||||
# --with github.com/lolPants/caddy-requestid
|
||||
|
||||
FROM caddy:2.10.0 AS run
|
||||
|
||||
# COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
22
test/caddy/docker-compose.yaml
Normal file
22
test/caddy/docker-compose.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
services:
|
||||
caddy:
|
||||
image: xxxtest/caddy
|
||||
build: .
|
||||
ports:
|
||||
- 8080:80
|
||||
- 8443:443
|
||||
volumes:
|
||||
- "../pki/caddy.local.cetacean.club:/etc/techaro/pki/caddy.local.cetacean.club/"
|
||||
|
||||
anubis:
|
||||
image: ghcr.io/techarohq/anubis:main
|
||||
environment:
|
||||
BIND: ":3000"
|
||||
TARGET: http://httpdebug:3000
|
||||
POLICY_FNAME: /etc/techaro/anubis/less_paranoid.yaml
|
||||
volumes:
|
||||
- ../anubis_configs:/etc/techaro/anubis
|
||||
|
||||
httpdebug:
|
||||
image: ghcr.io/xe/x/httpdebug
|
||||
pull_policy: always
|
22
test/caddy/start.sh
Normal file
22
test/caddy/start.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# If the transient local TLS certificate doesn't exist, mint a new one
|
||||
if [ ! -f ../pki/caddy.local.cetacean.club/cert.pem ]; then
|
||||
# Subshell to contain the directory change
|
||||
(
|
||||
cd ../pki \
|
||||
&& mkdir -p caddy.local.cetacean.club \
|
||||
&& \
|
||||
# Try using https://github.com/FiloSottile/mkcert for better DevEx,
|
||||
# but fall back to using https://github.com/jsha/minica in case
|
||||
# you don't have that installed.
|
||||
(
|
||||
mkcert \
|
||||
--cert-file ./caddy.local.cetacean.club/cert.pem \
|
||||
--key-file ./caddy.local.cetacean.club/key.pem caddy.local.cetacean.club \
|
||||
|| go tool minica -domains caddy.local.cetacean.club
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
||||
docker compose up --build
|
Loading…
x
Reference in New Issue
Block a user