Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend Rule evolution #437

Closed
WTFKr0 opened this issue Jun 6, 2016 · 8 comments
Closed

Frontend Rule evolution #437

WTFKr0 opened this issue Jun 6, 2016 · 8 comments
Labels

Comments

@WTFKr0
Copy link
Contributor

WTFKr0 commented Jun 6, 2016

Hi

I would like to tell the frontend rule like that :
traefik.frontend.rule=Host:myapp.${default_traefik_domain}

I need that cause I have some docker-compose templates shared between independant docker host. Each host has his own traefik container with his own domain name

Is that possible ?

@emilevauge
Copy link
Member

emilevauge commented Jun 6, 2016

@WTFKr0 the default behavior is Host:{containerName}.{domain}). I think this is exactly what you need ;)

@WTFKr0
Copy link
Contributor Author

WTFKr0 commented Jun 6, 2016

Not really, I want to let the default container name but add a front-end rule to myapp.{domain}

@emilevauge emilevauge added the kind/enhancement a new or improved feature. label Jun 9, 2016
@emilevauge
Copy link
Member

In this case, I think the most generic way would be to add default frontends rules for a traefik instance.

@samber
Copy link
Contributor

samber commented Jun 11, 2016

Yes, and wildcards would be a very good friend !

@WTFKr0
Copy link
Contributor Author

WTFKr0 commented Jul 7, 2016

I think we can close that, thanx !

@WTFKr0
Copy link
Contributor Author

WTFKr0 commented Jul 29, 2016

I think about this and this is what i'm loogink for :

I got a traefik instance listening docker events, with docker.domain=mydomain.org
I got container named c1, that i dont want to change the name

No Ive got 2 choices :

  1. without labels
docker run myimage
=> Creates a frontend c1.mydomain.org
  1. with label
docker run -l "traefik.frontend.rule=Host:cont1.mydomain.org" myimage
=> Creates a frontend cont1.mydomain.org

But I need abstraction of the default domain, cause I have multiple traefik instance with different default domains, and want same command to run container on each.

I think the function getSubDomain need to be update to get a label instead of compute data from container name
Here : https://github.com/containous/traefik/blob/ae31f19ef65a1cea4f741aa030827e0f4957eaf7/provider/docker.go#L366

So I want to do with a new label :

docker run -l "traefik.frontend.subdomain=cont1" myimage
=> Creates a frontend cont1.${default_traefik_domain}

Did you see what I want ?

Thanx for reading
@emilevauge
@vdemeester

@gaui
Copy link

gaui commented Jan 25, 2018

This is EXACTLY what I need. Why was this closed? This would be really beneficial for those who are aiming at infrastructure-as-code with Terraform and trying to seperate domain/DNS/zones from frontend rules and want to keep their Docker stack/compose files "stateless" and not coupled to the environment/domain/DNS zone.

I'm using Terraform to span up a Docker Swarm for 3 different workspaces / VPCs (dev, staging, production) and using Træfik on each of them....... The traefik.toml is set up on the server initially when the instance is provisioned and the docker.domain is specified in it based on my DNS zone Terraform resource (based on terraform.workspace variable, where it's dev, staging or prod), and I keep my Docker stack/compose files seperate without specifying domain in each of them (because it varies between environments). Same Docker stack/compose file, different environments (VPC / DNS zones).

Let's say I want to use the same Docker stack file for 3 different DNS zones and 3 different Træfik instances... dev.domain.tld, staging.domain.tld, prod.domain.tld

I would like to specify myservice as a frontend/subdomain rule and it would work for all 3 different zones (based on docker.domain specified in the traefik.toml on the server), so the same Docker stack/compose file with myservice frontend rule in the Docker stack/compose file, would work for myservice.dev.domain.tld on Træfik instance on dev environment, myservice.staging.domain.tld on Træfik instance on staging environment and myservice.prod.domain.tld on Træfik instance on production environment.

@gaui
Copy link

gaui commented Jan 25, 2018

I know that when you create a Docker Swarm service the default frontend rule will be serviceName.dev.domain.tld if I specify docker.domain=dev.domain.tld in the TOML, but it would be better to be able to control the frontend rule.

I could use HostRegexp rule, something like traefik.frontend.rule=HostRegexp:customName.{subdomain:(dev|staging|prod)}.domain.tld but it's really hacky/messy and you're stuck with these 3 environments. What if I add a new VPC for our release/pre-prod environment?

I suggest to create a new variable ${domain} like @WTFKr0 suggested, that can be used in frontend rules, so you could set docker.domain=dev.domain.tld (generated via TOML template file in Terraform) and then in stack file, use traefik.frontend.rule=Host:customName.${domain} and that would be translated to Host:customName.dev.domain.tld or whatever domain is set in the TOML. Then people could be in same control, without having to couple the domain to the Docker stack/compose file.

Please re-open this @emilevauge

@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants