template.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. ---
  2. kind: compose
  3. schema: "1.1"
  4. metadata:
  5. name: Traefik
  6. description: >
  7. Traefik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy.
  8. This template sets up Traefik with automatic HTTPS using Let's Encrypt and can be integrated with Authentik for SSO.
  9. Project: https://traefik.io/
  10. Documentation: https://doc.traefik.io/traefik/
  11. version: v3.5.3
  12. author: "Christian Lempa"
  13. date: "2025-10-02"
  14. tags:
  15. - reverse-proxy
  16. - load-balancer
  17. next_steps: |
  18. 1. Start Traefik:
  19. docker compose up -d
  20. 2. Configure your domain DNS:
  21. - Point your domain A/AAAA records to your server IP
  22. {% if traefik_tls_enabled -%}
  23. - Configure DNS API credentials in .env file
  24. - Ensure {{ traefik_tls_acme_provider }} API token has DNS edit permissions
  25. {%- endif %}
  26. 3. Access the dashboard:
  27. {% if traefik_dashboard_enabled -%}
  28. - Dashboard: http://localhost:8080
  29. - WARNING: Dashboard is in insecure mode - don't use in production!
  30. {%- else -%}
  31. - Dashboard is disabled (secure production setup)
  32. - Enable it temporarily by setting traefik_dashboard_enabled=true
  33. {%- endif %}
  34. 4. Deploy your services:
  35. - Ensure services use the '{{ network_name }}' network
  36. - Add Traefik labels to your service containers
  37. - Services will be automatically discovered and routed
  38. 5. Configuration files:
  39. - Static config: config/traefik.yml
  40. - Dynamic config: config/conf.d/*.yml
  41. {% if traefik_tls_enabled -%}
  42. - TLS certificates: certs/acme.json
  43. {%- endif %}
  44. 6. Security recommendations:
  45. - Disable dashboard in production (traefik_dashboard_enabled=false)
  46. - Use TLS/HTTPS for all services
  47. - Store API tokens in Docker secrets (Swarm) or secure vaults
  48. - Regularly update Traefik to latest version
  49. - Review and limit network exposure
  50. For more information, visit: https://doc.traefik.io/traefik/
  51. draft: true
  52. spec:
  53. general:
  54. title: "General"
  55. required: true
  56. vars:
  57. service_name:
  58. default: "traefik"
  59. container_name:
  60. default: "traefik"
  61. accesslog_enabled:
  62. type: "bool"
  63. description: "Enable Traefik access log"
  64. default: false
  65. traefik:
  66. title: "Traefik Settings"
  67. description: "Configure Traefik as a reverse proxy"
  68. required: true
  69. vars:
  70. traefik_entrypoint:
  71. type: "str"
  72. description: "HTTP entrypoint name (non-TLS)"
  73. default: "web"
  74. extra: "Standard HTTP traffic on port 80"
  75. traefik_dashboard_enabled:
  76. type: "bool"
  77. description: "Enable Traefik dashboard (insecure mode)"
  78. default: false
  79. extra: "WARNING: Don't use in production! Exposes dashboard on port 8080"
  80. traefik_tls:
  81. title: "Traefik TLS Settings"
  82. description: "Configure TLS/SSL with Let's Encrypt ACME"
  83. needs: null
  84. vars:
  85. traefik_tls_enabled:
  86. type: "bool"
  87. description: "Enable HTTPS/TLS with ACME"
  88. default: false
  89. traefik_tls_acme_provider:
  90. type: "enum"
  91. description: "ACME DNS challenge provider"
  92. default: "cloudflare"
  93. options:
  94. - "cloudflare"
  95. extra: "DNS provider for domain validation"
  96. traefik_tls_acme_token:
  97. type: "str"
  98. description: "DNS provider API token"
  99. sensitive: true
  100. extra: "For Cloudflare, create an API token with Zone:DNS:Edit permissions. Leave empty to use Docker Swarm secrets."
  101. traefik_tls_acme_secret_name:
  102. type: "str"
  103. description: "Docker Swarm secret name for API token (swarm mode only)"
  104. default: "cloudflare_api_token"
  105. extra: "The secret name to use in Docker Swarm for storing the API token"
  106. traefik_tls_acme_email:
  107. type: "str"
  108. description: "Email address for ACME (Let's Encrypt) registration"
  109. default: "admin@example.com"
  110. extra: "Required for Let's Encrypt certificate requests"
  111. traefik_tls_redirect:
  112. type: "bool"
  113. description: "Redirect all HTTP traffic to HTTPS"
  114. default: true
  115. ports:
  116. toggle: "ports_enabled"
  117. vars:
  118. traefik_http_port:
  119. type: "int"
  120. description: "HTTP port (external)"
  121. default: 80
  122. extra: "Maps to entrypoint 'web' (port 80)"
  123. traefik_https_port:
  124. type: "int"
  125. description: "HTTPS port (external)"
  126. default: 443
  127. extra: "Maps to entrypoint 'websecure' (port 443)"
  128. network:
  129. vars:
  130. network_enabled:
  131. default: true
  132. network_mode:
  133. default: "bridge"
  134. network_name:
  135. default: "proxy"
  136. network_external:
  137. default: false
  138. authentik:
  139. title: Authentik Middleware
  140. description: Enable Authentik SSO integration for Traefik
  141. vars:
  142. authentik_outpost_url:
  143. type: "url"
  144. description: "Authentik outpost URL (e.g., http://authentik-outpost:9000)"
  145. default: "http://authentik-outpost:9000"
  146. traefik_authentik_middleware_name:
  147. type: "str"
  148. description: "Name of the Authentik middleware"
  149. default: "authentik"
  150. extra: "Reference this in router labels as '{name}@file'"