-
Notifications
You must be signed in to change notification settings - Fork 0
/
Caddyfile
30 lines (26 loc) · 974 Bytes
/
Caddyfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
servers {
# We trust (configurably) X-Forwarded-For headers from traffic that's proxied through
# localhost, e.g. through SCW's Envoy container proxy. Without this all traffic appears
# to come directly from localhost, ignoring the data Envoy passes through.
trusted_proxies static {$TRUSTED_PROXIES:127.0.0.1}
}
}
# We use the domain name (via Host header) to decide which upstream service we
# should forward the traffic to:
{$EVENTS_DOMAIN:events.httptoolkit.tech}:{$PORT:8080} {
reverse_proxy https://eu.posthog.com {
# We need to use the correct hostname for upstream requests:
header_up Host {upstream_hostport}
# Anonymize ip addresses when forwarding:
header_up X-Forwarded-For "\.\d{0,3}(,\s*|$)" ".0$1"
}
}
# For any other unrecognized services, we reject the request outright:
:80, :443, :{$PORT:8080} {
log
respond 400 {
body "Unrecognized host name"
close
}
}