1- # Caddyfile for MONAI Breast Density Classification
2- # Simple reverse proxy to auth-gateway service
3-
4- # Main site configuration
5- :23434 {
6- # TLS configuration using provided certificates
7- tls /etc/ssl/certs/fullchain.pem /etc/ssl/private/privkey.pem
8-
9- # Reverse proxy all requests to auth-gateway
10- reverse_proxy auth-gateway:8090 {
11- # Health check for upstream
12- health_uri /health
13- health_interval 30s
14- health_timeout 10s
15-
16- # Forward original client information
17- header_up Host {host}
18- header_up X-Real-IP {remote_host}
19- header_up X-Forwarded-For {remote_host}
20- header_up X-Forwarded-Proto {scheme}
21- header_up X-Forwarded-Port {server_port}
22- }
23-
24- # Request/response logging for debugging (optional)
25- log {
26- output stdout
27- format console
28- level INFO
29- }
30-
31- # Security headers
32- header {
33- # Remove server identification
34- -Server
35- # Basic security headers
36- X-Content-Type-Options nosniff
37- X-Frame-Options DENY
38- X-XSS-Protection "1; mode=block"
39- Referrer-Policy strict-origin-when-cross-origin
40- }
41-
42- # Handle specific endpoints with better error pages
43- handle_errors {
44- @502 expression {http.error.status_code} == 502
45- @503 expression {http.error.status_code} == 503
46- @504 expression {http.error.status_code} == 504
47-
48- respond @502 "Service temporarily unavailable - auth-gateway not ready" 502
49- respond @503 "Service temporarily unavailable - please try again" 503
50- respond @504 "Service timeout - request took too long" 504
51- }
1+ {
2+ debug
3+ order claive_reverse_proxy first
4+ log {
5+ output stdout
6+ format console
7+ level DEBUG
8+ }
529}
5310
54- # Optional: Redirect HTTP to HTTPS if needed
55- # :80 {
56- # redir https://{host}:23434{uri} permanent
57- # }
11+ # HTTP to HTTPS redirect (eliminates TLS handshake errors)
12+ fetchai.scrtlabs.com:80 {
13+ redir https://fetchai.scrtlabs.com:23434{uri} permanent
14+ }
15+
16+ # Main HTTPS site configuration for fetchai.scrtlabs.com
17+ fetchai.scrtlabs.com:23434 {
18+ # TLS configuration using provided certificates
19+ tls /etc/ssl/certs/fullchain.pem /etc/ssl/private/privkey.pem
20+
21+ @cors_preflight method OPTIONS
22+ handle @cors_preflight {
23+ header {
24+ Access-Control-Allow-Origin "{header.origin}"
25+ Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
26+ Access-Control-Allow-Headers "Content-Type, Authorization, Referrer-Policy, priority, sec-ch-ua, sec-ch-ua-mobile, sec-ch-ua-platform"
27+ Access-Control-Allow-Credentials "true"
28+ Vary Origin
29+ Access-Control-Max-Age "3600"
30+ }
31+ respond "" 204
32+ }
33+
34+ handle {
35+ header {
36+ Access-Control-Allow-Origin "{header.origin}"
37+ Access-Control-Allow-Headers "Content-Type, Authorization, Referrer-Policy, priority, sec-ch-ua, sec-ch-ua-mobile, sec-ch-ua-platform"
38+ Access-Control-Allow-Credentials "true"
39+ Vary Origin
40+ }
41+ claive_reverse_proxy {
42+ API_MASTER_KEY bWFzdGVyQHNjcnRsYWJzLmNvbTpTZWNyZXROZXR3b3JrTWFzdGVyS2V5X18yMDI1
43+ }
44+ reverse_proxy auth-gateway:8090 {
45+ # Health check for upstream
46+ health_uri /health
47+ health_interval 30s
48+ health_timeout 10s
49+
50+ # Forward original client information
51+ header_up Host {host}
52+ header_up X-Real-IP {remote_host}
53+ header_up X-Forwarded-Port {server_port}
54+ }
55+ }
56+
57+ # Security headers
58+ header {
59+ # Remove server identification
60+ -Server
61+ # Basic security headers
62+ X-Content-Type-Options nosniff
63+ X-Frame-Options DENY
64+ X-XSS-Protection "1; mode=block"
65+ Referrer-Policy strict-origin-when-cross-origin
66+ }
67+
68+ # Handle specific endpoints with better error pages
69+ handle_errors {
70+ @502 expression {http.error.status_code} == 502
71+ @503 expression {http.error.status_code} == 503
72+ @504 expression {http.error.status_code} == 504
73+
74+ respond @502 "Service temporarily unavailable - auth-gateway not ready" 502
75+ respond @503 "Service temporarily unavailable - please try again" 503
76+ respond @504 "Service timeout - request took too long" 504
77+ }
78+ }
0 commit comments