Multiple routes for one service #125
Replies: 2 comments 4 replies
|
Thanks for the kind words, and good news: this already works today. You do not need one service per domain. A single route can match as many domains as you like, and it produces exactly one router and one service. How to do it
The chip list is built from the domains in Settings -> Connection, plus any domains auto-detected from your existing routes, plus anything you add with +. If you are going to reuse these five domains a lot, adding them under Settings -> Connection means they are always there. What that writesSelecting five domains with subdomain http:
routers:
local-traefik:
rule: Host(`app.d1.com`) || Host(`app.d2.com`) || Host(`app.d3.com`) || Host(`app.d4.com`) || Host(`app.d5.com`)
service: local-traefik-service
services:
local-traefik-service:
loadBalancer:
servers:
- url: http://10.0.0.50:80One router, one service, one backend definition. Leaving the Subdomain field empty instead gives you Editing the route later re-selects the domains it already matches, so you can add or remove one without retyping the rule. More detail in the Routes tab docs. One thing worth checkingIf what you actually want is five separate routers that happen to share one service, because each domain needs different middlewares, a different entry point or its own TLS settings, then that is a different thing and the UI does not currently create it. Each route in the modal owns its own service, named after the route. Traefik Manager will not break such a setup if you write it by hand: it keeps an existing service reference when you edit a route, and deleting one router no longer removes a service another router still points at. But there is no "use an existing service" picker in the modal. Does any of your five domains need its own middlewares or TLS, or do all five behave identically? If they are identical, the multi-domain rule above is all you need. If they differ per domain, say so and I will reopen this as a feature request for reusing a service across routes. |
|
Thank you very much for all the detailed information. I realize I wasn't specific enough, so here's a concrete example of what I'm trying to achieve. I want to route multiple subdomains to the same backend service, which is one of my local Traefik instances. However, I want each subdomain to have its own set of middlewares. In other words, I'd like to be able to define multiple routers, each with different middlewares, while all pointing to the same service. For example: app1.domain.com → mid1 → Local Traefik 1 At the moment, this requires creating multiple services that all have the exact same configuration, even though they all point to the same backend. It would be much cleaner if several routers could simply reference the same service while applying their own middlewares. |
Uh oh!
There was an error while loading. Please reload this page.
I have a front-facing Traefik instance that performs SSL termination and routes requests to multiple local Traefik instances.
It would be a great improvement if a single service could be associated with multiple domains. In my setup, I have five different domains configured on the front-facing Traefik, all of which need to point to the same backend service (a local Traefik instance).
Currently, this requires creating multiple services with identical configurations, differing only by the domain name. Allowing multiple domains to reference a single service would simplify the configuration, reduce duplication, and make maintenance much easier.
Thanks for all the amazing work you've done on this project !
All reactions