Route Subdomains Using Internal DNS

I have a couple of scenarios where I have multiple sub domains pointing to the same internal server. I have HAProxy on the router that is the target for all of the sub domains on the external/public DNS. Internally I have an Unbound DNS server that has the list of which sub domains map to which IP address/server. I’d like to avoid having to configure this map of subdomain to IP address in haproxy as well since that’s just asking for hours of troubleshooting when I forget to update both places. Also, of note, I have NAT setup to route WAN traffic on port 443 to the
port 9999 for now.

First scenario is a kubernetes cluster with traefik ingress. In this case it’s simple. All sub domains that map to the ingress IP address should just pass through port 443 to port 443. No need for any manipulation. I just need a way to capture all of these subdomains.

Second scenario is a small server with multiple small services with web frontends and no reverse proxy, so I want to use haproxy for that. So I’d like to set up a map in haproxy for the ports and have it default to port 443 for any that aren’t in the map.

I set up a resolver for the internal DNS server and tried setting up a frontend like:

frontend k8s-ingress-service
bind :9999 name and :9999
mode http
option http-keep-alive
acl k8s-acl dst
use_backend k8s-pool if k8s-acl

backend k8s-pool
mode http
server k8s-ingress k8s-ingress.:443 resolve-prefer ipv4

But it’s not getting triggered. I’m not sure if that’s the right way to go as I’m pretty new to haproxy. So I’m not sure when the DNS resolution happens, so I’m not sure where to put the rule. And I’m not sure if it’s that or the bind isn’t working or some other issue.

So, any suggestions or general help understanding the flow with DNS resolution would be greatly appreciated just to get me started.