I haven't attempted that setup however I've got a Nginx server acting as a reverse proxy which implements DNS-over-TLS.
Android 9 has support for custom private DNS servers so I just point it to my home IP and works great, no adverts when I'm out of the house.