Caddyfile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. {
  2. # Global options - HTTP only (SSL терминируется на Synology)
  3. admin off
  4. http_port 80
  5. }
  6. # API subdomain - проксирует на backend + MinIO S3 API + MinIO Console
  7. api.{$DOMAIN} {
  8. # MinIO Console: /minio-console/* -> minio:9001 (с stripping пути)
  9. @minioConsole {
  10. path /minio-console/*
  11. }
  12. handle_path @minioConsole {
  13. reverse_proxy minio:9001 {
  14. header_up Host {host}
  15. header_up X-Real-IP {remote}
  16. header_up X-Forwarded-For {remote}
  17. header_up X-Forwarded-Proto {scheme}
  18. }
  19. }
  20. # MinIO S3 API: /s3/* -> minio:9000
  21. @s3 {
  22. path /s3/*
  23. }
  24. reverse_proxy @s3 minio:9000 {
  25. header_up Host {host}
  26. header_up X-Real-IP {remote}
  27. header_up X-Forwarded-For {remote}
  28. header_up X-Forwarded-Proto {scheme}
  29. }
  30. # Backend API: всё остальное -> backend:8080
  31. reverse_proxy backend:8080 {
  32. header_up Host {host}
  33. header_up X-Real-IP {remote}
  34. header_up X-Forwarded-For {remote}
  35. header_up X-Forwarded-Proto {scheme}
  36. }
  37. # Security headers (HSTS на Synology, здесь — остальное)
  38. header {
  39. X-Content-Type-Options "nosniff"
  40. X-Frame-Options "DENY"
  41. Referrer-Policy "strict-origin-when-cross-origin"
  42. Permissions-Policy "geolocation=(), microphone=(), camera=()"
  43. }
  44. # Rate limiting at proxy level (backup to app-level)
  45. @auth {
  46. path /api/v1/auth/*
  47. }
  48. rate_limit @auth {
  49. zone auth
  50. rate 10/minute
  51. key {remote}
  52. }
  53. }
  54. # Frontend main domain
  55. {$DOMAIN} {
  56. reverse_proxy frontend:3000 {
  57. header_up Host {host}
  58. header_up X-Real-IP {remote}
  59. header_up X-Forwarded-For {remote}
  60. header_up X-Forwarded-Proto {scheme}
  61. }
  62. # Security headers
  63. header {
  64. X-Content-Type-Options "nosniff"
  65. X-Frame-Options "DENY"
  66. Referrer-Policy "strict-origin-when-cross-origin"
  67. Permissions-Policy "geolocation=(), microphone=(), camera=()"
  68. 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';"
  69. }
  70. # Static assets caching
  71. @static {
  72. path /_next/static/*
  73. path /static/*
  74. path /images/*
  75. path /favicon.ico
  76. }
  77. header @static Cache-Control "public, max-age=31536000, immutable"
  78. # Compression
  79. encode zstd gzip
  80. }
  81. # MinIO Console доступен по: https://api.photoplaces.ru/minio-console/
  82. # (через Caddy path-based routing, SSL на Synology)