-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaddyfile
More file actions
45 lines (40 loc) · 1.2 KB
/
Caddyfile
File metadata and controls
45 lines (40 loc) · 1.2 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Standard headers - Caddy automatically handles X-Forwarded-For, X-Forwarded-Proto, etc.
# We just add X-Real-IP for compatibility with some applications
(standard_headers) {
# Caddy automatically handles X-Forwarded-For correctly
# Just set X-Real-IP for apps that prefer that header
header_up X-Real-IP {http.request.remote.host}
}
# Cloudflare-specific headers - use when behind Cloudflare
# This overrides the automatic forwarding with Cloudflare's trusted headers
(cloudflare_headers) {
header_up X-Real-IP {http.request.header.CF-Connecting-IP}
header_up X-Forwarded-For {http.request.header.CF-Connecting-IP}
}
# API site
{$API_DOMAIN} {
@ws {
header Connection *Upgrade*
header Upgrade websocket
}
# Handle WebSocket connections with proper header forwarding
reverse_proxy @ws {$CONTROLLER_UPSTREAM} {
import standard_headers
header_up Connection {http.request.header.Connection}
header_up Upgrade {http.request.header.Upgrade}
}
# Handle regular HTTP requests
reverse_proxy {$CONTROLLER_UPSTREAM} {
import standard_headers
}
}
# App site
{$APP_DOMAIN} {
@ws {
header Connection *Upgrade*
header Upgrade websocket
}
reverse_proxy {$PANEL_UPSTREAM} {
import standard_headers
}
}