From 28b9abf1dd9da62e540eb7a0672a7ebedc308fbd Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Tue, 2 Feb 2021 14:15:13 +0300 Subject: [PATCH] Pull request: dnsforward: don't redirect doh queries Merge in DNS/adguard-home from 2628-no-redirect to master Updates #2628. Squashed commit of the following: commit 686f3254bed1c84fe79aa203c1da4db243f301e3 Author: Ainar Garipov Date: Tue Feb 2 13:51:16 2021 +0300 dnsforward: don't redirect doh queries --- internal/dnsforward/http.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/dnsforward/http.go b/internal/dnsforward/http.go index e96c6c3f..e7508bc8 100644 --- a/internal/dnsforward/http.go +++ b/internal/dnsforward/http.go @@ -529,5 +529,13 @@ func (s *Server) registerHandlers() { s.conf.HTTPRegister(http.MethodGet, "/control/access/list", s.handleAccessList) s.conf.HTTPRegister(http.MethodPost, "/control/access/set", s.handleAccessSet) + // Register both versions, with and without the trailing slash, to + // prevent a 301 Moved Permanently redirect when clients request the + // path without the trailing slash. Those redirects break some clients. + // + // See go doc net/http.ServeMux. + // + // See also https://github.com/AdguardTeam/AdGuardHome/issues/2628. + s.conf.HTTPRegister("", "/dns-query", s.handleDOH) s.conf.HTTPRegister("", "/dns-query/", s.handleDOH) }