Caddyfile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Caddyfile for client2server
  2. # Single port (:3843) serves WebSocket and HTTP API; Caddy load-balances
  3. # across server1 and server2 in the Docker network.
  4. {
  5. # Global options
  6. # email your@email.com
  7. admin off
  8. auto_https off
  9. }
  10. # ========================================
  11. # Unified WebSocket + HTTP load balancer (:3843)
  12. # ========================================
  13. :3843 {
  14. # Backend servers (Docker network DNS)
  15. reverse_proxy server1:3843 server2:3843 {
  16. # Health check each backend
  17. health_uri /health
  18. health_interval 10s
  19. health_timeout 5s
  20. health_status 2xx
  21. # Load balancing policy
  22. lb_policy round_robin
  23. # WebSocket support (long-lived connections)
  24. # Caddy auto-detects Upgrade headers, no explicit directive needed
  25. }
  26. # Preserve client info
  27. header_up X-Real-IP {remote}
  28. header_up X-Forwarded-For {remote}
  29. header_up X-Forwarded-Proto {scheme}
  30. # Timeouts for long-lived WebSocket connections
  31. timeouts {
  32. read 300s
  33. write 300s
  34. idle 300s
  35. }
  36. }
  37. # ========================================
  38. # Dashboard (port 80) - React SPA via separate Caddy in dashboard container
  39. # ========================================
  40. :80, :443 {
  41. reverse_proxy dashboard:80
  42. }
  43. # ========================================
  44. # TLS for HTTPS (optional - requires auto_https on)
  45. # ========================================
  46. # tls {
  47. # # Let's Encrypt (automatic)
  48. # }