|
28 | 28 | } |
29 | 29 |
|
30 | 30 | # Domain Access Control |
31 | | - @allowed_domain { |
32 | | - # If CADDY_DOMAINS is not set, allow all |
33 | | - expression {env.CADDY_DOMAINS} == "" |
34 | | - # Or if the host matches the allowed list |
35 | | - host {$CADDY_DOMAINS} |
36 | | - } |
37 | | - |
38 | | - # Deny everything else if CADDY_DOMAINS is set |
39 | | - handle @allowed_domain { |
40 | | - # Main Reverse Proxy Logic |
41 | | - handle { |
42 | | - encode zstd gzip |
43 | | - |
44 | | - # Harden security posture |
45 | | - header { |
46 | | - Strict-Transport-Security "max-age=31536000;" |
47 | | - X-Content-Type-Options "nosniff" |
48 | | - X-Frame-Options "DENY" |
49 | | - X-XSS-Protection "1; mode=block" |
50 | | - Referrer-Policy "strict-origin-when-cross-origin" |
51 | | - Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()" |
52 | | - X-Robots-Tag "noindex, nofollow" |
53 | | - -Server |
54 | | - -X-Powered-By |
55 | | - -Last-Modified |
56 | | - } |
| 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 | + } |
57 | 51 |
|
58 | | - # Proxy to the application backend |
59 | | - reverse_proxy 127.0.0.1:8080 { |
60 | | - header_up X-Real-IP {http.request.header.Fly-Client-IP} |
61 | | - header_up X-Forwarded-For {http.request.header.Fly-Client-IP} |
62 | | - } |
| 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} |
63 | 56 | } |
64 | 57 | } |
65 | 58 |
|
|
0 commit comments