Use Path rule with tls

Hello,

I'm using the Path-rule to deliver a robots.txt in the root directory.
Traefik is configured to use port 80 (entrypoint http) and port 443 (entrypoint https), http to https redirection is configured.

- traefik.enable=true
- traefik.http.routers.traefik-static-files.rule=Path(`/robots.txt`)
- traefik.http.routers.traefik-static-files.priority=1000
- traefik.http.routers.traefik-static-files.entrypoints=https
- traefik.http.routers.traefik-static-files.tls=true
- traefik.http.services.traefik-static-files.loadbalancer.server.port=8080

Everything is working as expected, but I'm getting the following warning in the traefik logs:

No domain found in rule Path(/robots.txt), the TLS options applied for this router will depend on the hostSNI of each request.

Is there any solution to get rid of this warning?

If I remove the tls=true option, the setup is not working anymore.

Thanks in advance!

I think you have missed to add host domain before like this....

  • traefik.http.routers.traefik-static-files.rule=(Host(`mydomain.com`) && Path(`/robots.txt`))

Just in case this rule should apply to several domains you can edit the rule as follows using OR

....rule=(Host(`example.com`) || PathPrefix(`/robots.txt`))

This will disable the warning and it works for multiple domains.

1 Like