Caddyfile 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/443) - placeholder
  39. # ========================================
  40. :80, :443 {
  41. respond / "client2server dashboard - not yet implemented" 200
  42. }
  43. # Dashboard placeholder (enable if you have a web UI)
  44. # :80 {
  45. # reverse_proxy dashboard:3000
  46. # }
  47. # ========================================
  48. # TLS for HTTPS (optional - requires auto_https on)
  49. # ========================================
  50. # tls {
  51. # # Let's Encrypt (automatic)
  52. # }