template.yaml 4.7 KB

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