[dnsdist] DoH: 302 redirecting / to a help page

Remi Gacogne remi.gacogne at powerdns.com
Mon Sep 16 09:13:03 UTC 2019

Hi Andrew,

On 9/16/19 11:03 AM,  wrote:
> I have the url as /dns-query in my addDOHLocal config, and in the case
> that users put the domain name in to their browser address bar I'm
> wanting to redirect request to / to my help page.
> ie:
>   https://doh.mydomain.com/dns-query - for DoH lookups
>   https://doh.mydomain.com/ - redirect to another URL
> I'm thinking I need to use newDOHResponseMapEntry for  this, but I'm
> unsure how to add this to my config.
> This is what I'm trying (and failing with):
>  supportpage = newDOHResponseMapEntry("/", 302,
> "https://support.mydoman.com")
>  setResponsesMap(supportpage)

First, 'setResponsesMap' is not a standalone function but needs to be
applied to a DoH frontend, which is created with addDoHLocal().
It also takes a list of response map entries, not a single entry. Be
careful that newDOHResponseMapEntry() does take a regular expression, so
if you only want to match '/' you should write something like '^/$' instead.
So you need to do something like this:

supportpagemap = { newDOHResponseMapEntry("^/$", 302,
"https://support.mydoman.com") }
dohFE = getDOHFrontend(0)

It will only apply the map to the first DoH frontend (based on the '0'
index), so if you have more than one you'll have to carefully apply it
to all of them.

Best regards,
Remi Gacogne
PowerDNS.COM BV - https://www.powerdns.com/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.powerdns.com/pipermail/dnsdist/attachments/20190916/0ee50b8a/attachment.sig>

More information about the dnsdist mailing list