-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Possible to listen to both www.example.com and example.com? #116
Comments
@polds, you can add another frontend with |
I'm also having trouble setting this up. I have a backend defined:
Now I want this backend to be accessable through both mysite.nl and www.mysite.nl. I tried to do this:
Unfortunately this does not work, both mysite.nl and www.mysite.nl is resolving in |
@emilevauge Sorry I should have mentioned I'm using the Docker provider so not dealing with frontends. |
Hi @polds @rogierlommers, it's seems to be a bug :( Will look at it. |
same bug with consul provider and file provider. |
this is absolutely crazy to create new frontend for each rote, instead of creating routes for one frontend. |
And this kind of comment makes me wonder why this project is open source and free to use... |
I feel your pain. |
I just tested it using docker backend, and it seems to work (on the latest version): $ docker run -d -l traefik.backend=test -l traefik.frontend.rule=Host -l traefik.frontend.value=docker.localhost emilevauge/whoami
$ docker run -d -l traefik.backend=test -l traefik.frontend.rule=Host -l traefik.frontend.value=test.docker.localhost emilevauge/whoami
$ curl -s http://localhost:8080/api/providers | jq .
{
"docker": {
"frontends": {
"\"frontend-Host-test-docker-localhost\"": {
"routes": {
"\"route-frontend-Host-test-docker-localhost\"": {
"value": "test.docker.localhost",
"rule": "Host"
}
},
"backend": "backend-test"
},
"\"frontend-Host-docker-localhost\"": {
"routes": {
"\"route-frontend-Host-docker-localhost\"": {
"value": "docker.localhost",
"rule": "Host"
}
},
"backend": "backend-test"
}
},
"backends": {
"backend-test": {
"loadBalancer": {
"method": "wrr"
},
"servers": {
"server-cranky_kalam": {
"url": "http://172.17.0.3:80"
},
"server-admiring_cori": {
"url": "http://172.17.0.2:80"
}
}
}
}
}
}
$ curl http://docker.localhost
Hostname: 538097d25c11
IP: 127.0.0.1
IP: ::1
IP: 172.17.0.3
IP: fe80::42:acff:fe11:3
GET / HTTP/1.1
Host: 172.17.0.3:80
User-Agent: curl/7.35.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 10.0.1.18
X-Forwarded-Host: 172.17.0.3:80
X-Forwarded-Proto: http
X-Forwarded-Server: petiteboite
$ curl http://test.docker.localhost
Hostname: 9fbf1562c1f6
IP: 127.0.0.1
IP: ::1
IP: 172.17.0.2
IP: fe80::42:acff:fe11:2
GET / HTTP/1.1
Host: 172.17.0.2:80
User-Agent: curl/7.35.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 10.0.1.18
X-Forwarded-Host: 172.17.0.2:80
X-Forwarded-Proto: http
X-Forwarded-Server: petiteboite Using file backend with these rules seems also OK: [backends]
[backends.backend1]
[backends.backend1.LoadBalancer]
method = "wrr"
[backends.backend1.servers.server1]
url = "http://172.17.0.2:80"
weight = 1
[frontends]
[frontends.frontend1]
backend = "backend1"
[frontends.frontend1.routes.test_1]
rule = "Host"
value = "localhost"
[frontends.frontend2]
backend = "backend1"
[frontends.frontend2.routes.test_1]
rule = "Host"
value = "{subdomain:[a-z]+}.localhost" $ curl http://localhost
Hostname: 9fbf1562c1f6
IP: 127.0.0.1
IP: ::1
IP: 172.17.0.2
IP: fe80::42:acff:fe11:2
GET / HTTP/1.1
Host: 172.17.0.2:80
User-Agent: curl/7.35.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 127.0.0.1
X-Forwarded-Host: 172.17.0.2:80
X-Forwarded-Proto: http
X-Forwarded-Server: petiteboite
$ curl http://test.localhost
Hostname: 9fbf1562c1f6
IP: 127.0.0.1
IP: ::1
IP: 172.17.0.2
IP: fe80::42:acff:fe11:2
GET / HTTP/1.1
Host: 172.17.0.2:80
User-Agent: curl/7.35.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 10.0.1.18
X-Forwarded-Host: 172.17.0.2:80
X-Forwarded-Proto: http
X-Forwarded-Server: petiteboite Could you give more info on your conf? Could you test using my exemple? I know that using multiple frontends to do that is not perfect, but for now, this is a workaround. I'm planning to modify the behavior of routes, now there is a AND operation between routes from a frontend, and I think it would be more useful to have a OR. WDYT? |
@emilevauge you example works because you define two frontends:
But If you define one frontend and two routes for it, it doesn't:
|
@hd-deman, that's why I said:
|
@polds, is the issue still there? Because I cannot reproduce it here ;) |
Yeah if launched twice it works with no issues :) |
Using the wildcard subdomain you can listen to
{subdomain: [a-z]+}.example.com
, that however does not also includeexample.com
. Is it possible to listen to both?The text was updated successfully, but these errors were encountered: