traefik: Traefik should not serve requests for hosts which do not have a configuration defined
Do you want to request a feature or report a bug?
Bug
What did you do?
I’m just getting started with Traefik, and am playing around with running it as a local server to handle various docker images I may or may not start up. As part of this, I am exploring having it handle traffic on ports 80 & 443, and am running into a bit of a snag.
Static Configuration
web:
address: ":8080"
providers:
docker: {}
api:
insecure: true
log:
level: DEBUG
entryPoints:
web:
address: ":80/tcp"
http:
redirections:
entryPoint:
to: websecure
scheme: "https"
websecure:
address: ":443/tcp"
Starting the container
docker run --rm \
-p 80:80 \
-p 443:443 \
-p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v path/to/config.yml:/etc/traefik/traefik.yml:ro \
--name traefik traefik:2.2.1
What did you expect to see?
Nothing, really, as I have not configured any routes or services (other than the WebUI and API). The issue, instead, surfaces when browsing the web.
What did you see instead?
While the above container is running, when browsing the web, I encounter many “invalid certificate” errors. These show up in Traefik’s logs, too:
<snip>
time="2020-05-25T17:12:56Z" level=debug msg="No default certificate, generating one"
time="2020-05-25T17:14:47Z" level=debug msg="Serving default certificate for request: \"localhost\""
time="2020-05-25T17:14:47Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58378: remote error: tls: unknown certificate"
time="2020-05-25T17:14:50Z" level=debug msg="Serving default certificate for request: \"localhost\""
time="2020-05-25T17:16:15Z" level=debug msg="Serving default certificate for request: \"www.googletagservices.com\""
time="2020-05-25T17:16:15Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58392: remote error: tls: unknown certificate"
time="2020-05-25T17:16:20Z" level=debug msg="Serving default certificate for request: \"www.google-analytics.com\""
time="2020-05-25T17:16:20Z" level=debug msg="Serving default certificate for request: \"sb.scorecardresearch.com\""
time="2020-05-25T17:16:20Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58396: remote error: tls: unknown certificate"
time="2020-05-25T17:16:20Z" level=debug msg="Serving default certificate for request: \"secure.quantserve.com\""
time="2020-05-25T17:16:20Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58400: remote error: tls: unknown certificate"
time="2020-05-25T17:16:20Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58404: remote error: tls: unknown certificate"
time="2020-05-25T17:17:03Z" level=debug msg="Serving default certificate for request: \"collector.githubapp.com\""
time="2020-05-25T17:17:03Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58438: remote error: tls: unknown certificate"
time="2020-05-25T17:17:13Z" level=debug msg="Serving default certificate for request: \"collector.githubapp.com\""
time="2020-05-25T17:17:13Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58448: remote error: tls: unknown certificate"
time="2020-05-25T17:17:16Z" level=debug msg="Serving default certificate for request: \"collector.githubapp.com\""
time="2020-05-25T17:17:16Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58470: remote error: tls: unknown certificate"
time="2020-05-25T17:17:19Z" level=debug msg="Serving default certificate for request: \"collector.githubapp.com\""
time="2020-05-25T17:17:19Z" level=debug msg="http: TLS handshake error from 172.17.0.1:58478: remote error: tls: unknown certificate"
The reason that this occurs is because I block various tracker and ad domains via /etc/hosts
, by pointing them to 0.0.0.0
(this uses various adblock lists and is managed via the excellent pigmonkey/hostsctl
project). This causes requests to those domains to be redirected to my local machine, which Traefik then picks up (because it’s listening on port 443 on all interfaces).
Traefik tries to serve https://some-blocked-domain.com
, which there is no configuration for; in doing this it serves the default certificate created on startup which of course isn’t valid for the domain. My browser then throws warnings stating that the certificate is invalid.
I would expect Traefik to do the same thing that other servers do, and simply fail the request. I’m surprised to see that it instead serves the default certificate.
Output of traefik version
: (What version of Traefik are you using?)
Version: 2.2.1
Codename: chevrotin
Go version: go1.14.2
Built: 2020-04-29T18:02:09Z
OS/Arch: linux/amd64
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 15 (2 by maintainers)
Hello,
I would also support such option, besides the original issue described above the current behavior allows to identify traefik on a remote host just by connecting directly to the ip:
I agree with having an option to disable the default cert for unknown sites.
As others have mentioned, it’s very easy to determine what kind of web server is running when the
TRAEFIK DEFAULT CERT
is shown.It also responds to TLSv1 requests, even with
minVersion: VersionTLS12
set as a TLS Option.