wildcard-apps.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Wildcard routing for *.apps.briven.tech — every project subdomain
  2. # resolves to the control-plane API, which extracts the subdomain
  3. # (project slug or id) and dispatches to the runtime. This is the
  4. # public "call your function" URL shape: p_xxx.apps.briven.tech/<fn>.
  5. #
  6. # Deploy path (the controller drops this file via scp; Dokploy's
  7. # Traefik file-provider watches /etc/dokploy/traefik/dynamic/*.yml):
  8. #
  9. # scp infra/traefik/wildcard-apps.yml \
  10. # root@187.124.64.116:/etc/dokploy/traefik/dynamic/wildcard-apps.yml
  11. #
  12. # Traefik picks it up within seconds — no restart needed.
  13. #
  14. # TLS: wildcard cert via Let's Encrypt DNS-01 against Cloudflare.
  15. # The `cloudflare` cert resolver is defined in the Traefik static
  16. # config and reads CF_DNS_API_TOKEN from the container env (loaded
  17. # via --env-file /root/.briven-secrets/cloudflare.env). The token
  18. # is scoped to Zone:DNS:Edit + Zone:Read on briven.tech only.
  19. #
  20. # HostRegexp routers can't infer the cert domain on their own, so
  21. # the websecure router declares it explicitly in tls.domains.
  22. http:
  23. routers:
  24. wildcard-apps-web:
  25. # Plain HTTP -> redirect to HTTPS.
  26. rule: "HostRegexp(`^[a-z0-9-]+\\.apps\\.briven\\.cloud$`)"
  27. entryPoints:
  28. - web
  29. service: wildcard-apps-api
  30. middlewares:
  31. - redirect-to-https
  32. wildcard-apps-websecure:
  33. rule: "HostRegexp(`^[a-z0-9-]+\\.apps\\.briven\\.cloud$`)"
  34. entryPoints:
  35. - websecure
  36. service: wildcard-apps-api
  37. middlewares: []
  38. tls:
  39. certResolver: cloudflare
  40. domains:
  41. - main: "*.apps.briven.tech"
  42. sans:
  43. - "apps.briven.tech"
  44. services:
  45. wildcard-apps-api:
  46. loadBalancer:
  47. # Route to the same swarm service the regular API uses.
  48. # passHostHeader=true so the Hono middleware can read the
  49. # original subdomain and derive the project id.
  50. servers:
  51. - url: "http://app-hack-mobile-sensor-xw9qop:3001"
  52. passHostHeader: true