We have a Traefik that redirects to websecure scheme https permanent, but the issue is that the ip address is also redirected to https with an invalid default traefik certificate
My question is, how to prevent that?
Is it possible to drop any visit to a website by IP and only allow by domain?
If you want to redirect only requests to your correct domain to https, then you need to remove the redirect on entrypoint and instead create a redirect middleware on your router (doc). Don’t forget to assign the middleware to the router.
Alternatively you can also use your own default TLS cert or create a default one with LetsEncrypt. But then you reveal a domain to direct IP access requests.
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
certificatesResolvers:
myresolver:
^ this is the name you give to the resolver
similar to routers, middlewares and services
acme:
email: your-email@example.com
storage: acme.json
httpChallenge:
# used during the challenge
entryPoint: web
It seems to be working, visit the site by domain or ip gives me the cert generated for the domain, but in the logs I see this:
2025-09-15T07:11:08Z ERR Error while creating certificate store error="unable to find certificate for domains \"foo.bar\": falling back to the internal generated certificate" tlsStoreName=default