Public IP redirect

Hello! I have a scenario I can not figure out in Traefik.
I have a website example.com, with a public IP of 1.2.3.4.
The issue is that our client is scanning our website with a security scanner (vendor security program), and are entering 1.2.3.4 as the url, and getting the default traefik 404 page not found. The cert on the 404 page is the traefik default, and thus is flagged by the security scanner by not being a proper certificate.
I need to find if the request is coming in as 1.2.3.4, and redirect to example.com, or forward it to a custom 404 page that is behind our valid SSL cert. I am working with variations of the sample below, but none seem to be working, and keep hitting the [404 page not found] page behind the default traefik cert.

ip-catchall:
entryPoints:
- "https"
rule: "Host(1.2.3.4) || Host(https://1.2.3.5)"
middlewares:
- ip-redirect
service: ip-catchall

middlewares:
ip-redirect:
redirectRegex:
regex: "^https?://(.*)`"
replacement: "https://www.example.com"
permanent: true

Thanks,

I disagree, that you need to enable access with IP only. Http/s proxies are a valid tool on the Internet, why should you reveal your identity when some request just comes along with an IP? It could be any malicious actor on the Internet.

You can declare default certificates in Traefik that would be used for requests with unknown HostSNI (like IP only), both for custom TLS certs and for Traefik LetsEncrypt.

But TLS certs are always matched with a domain name. So even if you deliver such a domain cert by default, regular clients would usually reject it, as it doesn’t match the request (with IP only).