2828 }
2929
3030 # Domain Access Control
31- # Allow if CADDY_DOMAINS is empty OR host matches (using :localhost to avoid empty host error)
32- @allowed expression {env.CADDY_DOMAINS} == "" || host("{$CADDY_DOMAINS:localhost}" )
33-
34- # Main Application Logic (Only for allowed domains)
35- handle @allowed {
36- encode zstd gzip
37-
38- # Harden security posture
39- header {
40- Strict-Transport-Security "max-age=31536000;"
41- X-Content-Type-Options "nosniff"
42- X-Frame-Options "DENY"
43- X-XSS-Protection "1; mode=block"
44- Referrer-Policy "strict-origin-when-cross-origin"
45- Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
46- X-Robots-Tag "noindex, nofollow"
47- -Server
48- -X-Powered-By
49- -Last-Modified
50- }
51-
52- # Proxy to the application backend
53- reverse_proxy 127.0.0.1:8080 {
54- header_up X-Real-IP {http.request.header.Fly-Client-IP}
55- header_up X-Forwarded-For {http.request.header.Fly-Client-IP}
56- }
31+ @denied {
32+ expression {env.CADDY_DOMAINS} != ""
33+ not host {$CADDY_DOMAINS:localhost }
34+ }
35+ respond @denied "Access Denied: Domain not allowed" 403
36+
37+ encode zstd gzip
38+
39+ # Harden security posture
40+ header {
41+ Strict-Transport-Security "max-age=31536000;"
42+ X-Content-Type-Options "nosniff"
43+ X-Frame-Options "DENY"
44+ X-XSS-Protection "1; mode=block"
45+ Referrer-Policy "strict-origin-when-cross-origin"
46+ Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
47+ X-Robots-Tag "noindex, nofollow"
48+ -Server
49+ -X-Powered-By
50+ -Last-Modified
5751 }
5852
59- # Fallback for denied domains
60- handle {
61- respond "Access Denied: Domain not allowed" 403
53+ # Proxy to the application backend
54+ reverse_proxy 127.0.0.1:8080 {
55+ header_up X-Real-IP {http.request.header.Fly-Client-IP}
56+ header_up X-Forwarded-For {http.request.header.Fly-Client-IP}
6257 }
6358}
0 commit comments