ooF2oh
October 3, 2019, 6:44pm
1
Hello. I'm on Traefik 2.0.1. Not sure what I'm doing wrong here. I have this dynamic configuration:
http:
routers:
router0:
entryPoints:
- web
middlewares:
- httpsRedirect
service: myService
rule: Host(`example.com`)
router1:
entryPoints:
- webSecure
service: myService
rule: Host(`example.com`)
tls:
options: default
middlewares:
httpsRedirect:
redirectScheme:
scheme: https
services:
myService:
loadBalancer:
servers:
- url: http://localhost:8080
But, I'm getting these errors on startup:
"entryPointName":"web","msg":"the service \"myService@file\" does not exist","routerName":"router0@file"
"entryPointName":"webSecure","msg":"the service \"myService@file\" does not exist","routerName":"router1@file"
However, you can clearly see that myService
is defined in the services
block. What am I missing?
ldez
October 3, 2019, 7:02pm
2
Hello,
It's aYAML issue: the indentation of the blocks middlewares
and services
is wrong.
http:
routers:
router0:
entryPoints:
- web
middlewares:
- httpsRedirect
service: myService
rule: Host(`example.com`)
router1:
entryPoints:
- webSecure
service: myService
rule: Host(`example.com`)
tls:
options: default
middlewares:
httpsRedirect:
redirectScheme:
scheme: https
services:
myService:
loadBalancer:
servers:
- url: http://localhost:8080
1 Like
ooF2oh
October 3, 2019, 7:16pm
3
Hm... I updated my dynamic config to this:
http:
routers:
router0:
entryPoints:
- web
middlewares:
- httpsRedirect
service: myService
rule: Host(`example.com`)
router1:
entryPoints:
- webSecure
service: myService
rule: Host(`example.com`)
tls:
options: default
middlewares:
httpsRedirect:
redirectScheme:
scheme: https
services:
myService:
loadBalancer:
servers:
- url: http://localhost:8080
I added two mores spaces to entryPoints, middlewares, and servers.
But, still getting:
"entryPointName":"web","msg":"the service \"myService@file\" does not exist","routerName":"router0@file"
"entryPointName":"webSecure","msg":"the service \"myService@file\" does not exist","routerName":"router1@file"
I used some online YAML to TOML converter, maybe someone can spot something wrong in the TOML?
[http]
[http.routers]
[http.routers.router0]
entryPoints = [ "web" ]
middlewares = [ "httpsRedirect" ]
service = "myService"
rule = "Host(`example.com`)"
[http.routers.router1]
entryPoints = [ "webSecure" ]
service = "myService"
rule = "Host(`example.com`)"
[http.routers.router1.tls]
options = "default"
[http.routers.middlewares]
[http.routers.middlewares.httpsRedirect]
[http.routers.middlewares.httpsRedirect.redirectScheme]
scheme = "https"
[http.routers.services]
[http.routers.services.myService]
[http.routers.services.myService.loadBalancer]
[[http.routers.services.myService.loadBalancer.servers]]
url = "http://localhost:8080"
ooF2oh
October 3, 2019, 7:18pm
4
Also, I think the two spaces don't matter.
It appears that
foo:
- one
- two
- three
bar:
- one
- two
- three
are equivalent.
ldez
October 3, 2019, 7:30pm
5
I repeat: it's YAML indentation issue: routers
, middlewares
and services
must be at the same level:
http:
routers:
router0:
entryPoints:
- web
middlewares:
- httpsRedirect
service: myService
rule: Host(`example.com`)
router1:
entryPoints:
- webSecure
service: myService
rule: Host(`example.com`)
tls:
options: default
middlewares:
httpsRedirect:
redirectScheme:
scheme: https
services:
myService:
loadBalancer:
servers:
- url: http://localhost:8080
TOML is not indentation based (i.e. the indentation is not used)
[http.routers.router0]
entryPoints = ["web"]
middlewares = ["httpsRedirect"]
service = "myService"
rule = "Host(`example.com`)"
[http.routers.router1]
entryPoints = ["webSecure"]
service = "myService"
rule = "Host(`example.com`)"
[http.routers.router1.tls]
options = "default"
[http.middlewares.httpsRedirect.redirectScheme]
scheme = "https"
[http.services.myService.loadBalancer]
[[http.services.myService.loadBalancer.servers]]
url = "http://localhost:8080"
ooF2oh
October 3, 2019, 7:36pm
6
Aaaah, yep. That's what it was! Thanks!! I had services
under routers
, when it should have been on the same level. Just like you said.