Error pages 404

Hi.

I set up an error page from tarampampam

The goal is to intercept the wrong codes and produce a nice error page. But. If my domain is accessed incorrectly, for example subdomain.domain.com (I don't have such a router with such a subdomain), in this case the browser returns a 404 standard. And if you address my domain through a strange request, such as http://123.domain.com:443, the request is intercepted error-pages and gives a nice page. How can you make the router intercept all invalid requests?

Router error-pages

http:
  routers:
    error-pages:
      rule: "HostRegexp(`{host:.+}`)"
      entryPoints:
        - "https"
      service: error-pages
      priority: 1

  services:
    error-pages:
      loadBalancer:
        servers:
          - url: "http://error-pages:8080"

traefik.yml

entryPoints:
  http:
    address: :80
    http:
      middlewares:
        - error-pages@file
        - ip2location@file
        - geoblock@file
      redirections:
        entryPoint:
          to: https
          scheme: https

  https:
    address: :443
    http:
      middlewares:
        - error-pages@file
        - ip2location@file
        - geoblock@file
        - crowdsec-traefik-bouncer@file
        - rate-limit@file
        - gzip@file

Middlewares

  # Error Pages
    error-pages:
      errors:
        status:
          - "401-599"
        service: error-pages
        query: /{status}.html

In general, it would be nice to make built-in error pages in traefik :frowning:

Does the sub-domain point to the IP of your Traefik server? Do you have wildcard TLS certs set up?

When accessing a subdomain, the request goes to the server, it is visible in the logs. There are no wildcard certificates. I'm using lets encrypt

Even when using LE, you can create certs for individual domains or wildcard(s), depending on setup and challenge method.

The issue is; do you access nonexistig.domain.tld using https or http. Traefik doesn't know about if subdomains do exist so you need to have some logic and magic on the right places (which I was working on a while ago but did't finish yet)

Do you have a solution for the Traefik IP itself ? Same issue.

Can you give me a sample solution to get an error page from error-pages when accessing a non-existent subdomain?

The funny thing is that the subdomain to which it is addressed, once existed in my place and it has a certificate. When I access it, I get 404 and https.

But if I access a non-existent subdomain, I get SSL_ERROR

Example
test.domain.com - standard 404 (there is a certificate. The request is logged on the server, But it does not transmit complete information about the client)
test2.domain.com - SSL_ERROR (no certificate. The request is not logged on the server)

http://3234.domain.com:443 - 404 from error-pages (The request is logged on the server, and transmits complete information, including the country)

Of course, I also wonder if it is safe to use error-pages from tarampampam at all.

Multiple things:

  1. Your DNS provider needs to support wildcard DNS
  2. For TLS/SSL/https you need to provide a cert. This only works with wildcards, for LE you need more complicated dnsChallenge and set main and sans.

Complication: some browsers sometimes try to access an entered domain by https first, so you might run into errors without (2)