Caddyfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. {
  2. # Global options
  3. admin off
  4. http_port 80
  5. https_port 443
  6. }
  7. # API subdomain
  8. api.{$DOMAIN} {
  9. reverse_proxy backend:8080 {
  10. header_up Host {host}
  11. header_up X-Real-IP {remote}
  12. header_up X-Forwarded-For {remote}
  13. header_up X-Forwarded-Proto {scheme}
  14. }
  15. # Security headers
  16. header {
  17. Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  18. X-Content-Type-Options "nosniff"
  19. X-Frame-Options "DENY"
  20. Referrer-Policy "strict-origin-when-cross-origin"
  21. Permissions-Policy "geolocation=(), microphone=(), camera=()"
  22. }
  23. # Rate limiting at proxy level (backup to app-level)
  24. @auth {
  25. path /api/v1/auth/*
  26. }
  27. rate_limit @auth {
  28. zone auth
  29. rate 10/minute
  30. key {remote}
  31. }
  32. }
  33. # Frontend main domain
  34. {$DOMAIN} {
  35. reverse_proxy frontend:3000 {
  36. header_up Host {host}
  37. header_up X-Real-IP {remote}
  38. header_up X-Forwarded-For {remote}
  39. header_up X-Forwarded-Proto {scheme}
  40. }
  41. # Security headers
  42. header {
  43. Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  44. X-Content-Type-Options "nosniff"
  45. X-Frame-Options "DENY"
  46. Referrer-Policy "strict-origin-when-cross-origin"
  47. Permissions-Policy "geolocation=(), microphone=(), camera=()"
  48. Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' https://api-maps.yandex.ru; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' wss: https://api.{$DOMAIN} https://api-maps.yandex.ru; frame-ancestors 'none';"
  49. }
  50. # Static assets caching
  51. @static {
  52. path /_next/static/*
  53. path /static/*
  54. path /images/*
  55. path /favicon.ico
  56. }
  57. header @static Cache-Control "public, max-age=31536000, immutable"
  58. # Compression
  59. encode zstd gzip
  60. }
  61. # MinIO console (optional, restricted)
  62. minio.{$DOMAIN} {
  63. reverse_proxy minio:9001 {
  64. header_up Host {host}
  65. header_up X-Real-IP {remote}
  66. header_up X-Forwarded-For {remote}
  67. header_up X-Forwarded-Proto {scheme}
  68. }
  69. # Basic auth for MinIO console (add credentials to env)
  70. basicauth {
  71. {$MINIO_CONSOLE_USER} {$MINIO_CONSOLE_PASSWORD}
  72. }
  73. }