https

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

coredns-https

CI GitHub release

coredns-https provides the dohproxy CoreDNS plugin, which proxies DNS messages to upstream resolvers using DNS-over-HTTPS. See RFC 8484.

Installation

The plugin must be compiled into CoreDNS. The following commands build the latest plugin release against the tested CoreDNS version:

git clone --depth 1 --branch v1.14.6 https://github.com/coredns/coredns.git
cd coredns
go get github.com/v-byte-cpu/coredns-https@latest
COREDNS_PLUGINS="dohproxy:github.com/v-byte-cpu/coredns-https" go generate coredns.go
go build
./coredns -plugins | grep -Fx dohproxy

[!IMPORTANT] The Corefile directive was renamed from https to dohproxy to avoid a collision with the built-in CoreDNS https plugin. Prometheus metrics were also renamed from coredns_https_* to coredns_dohproxy_*.

Local development

Run the unit tests first:

go test ./...

To test the current checkout in a real CoreDNS binary, clone the tested CoreDNS version into a separate directory and replace the module with the absolute path to this repository:

git clone --depth 1 --branch v1.14.6 https://github.com/coredns/coredns.git
cd coredns
go mod edit -replace github.com/v-byte-cpu/coredns-https=/absolute/path/to/coredns-https
go get github.com/v-byte-cpu/coredns-https@v0.0.0
COREDNS_PLUGINS="dohproxy:github.com/v-byte-cpu/coredns-https" go generate coredns.go
go build
./coredns -plugins | grep -Fx dohproxy

Create a Corefile for a manual end-to-end check:

.:1053 {
    dohproxy . cloudflare-dns.com/dns-query
    errors
    log
}

Start CoreDNS, then query it from another terminal:

./coredns -conf Corefile
dig @127.0.0.1 -p 1053 example.org A

Syntax

In its most basic form:

dohproxy FROM TO...
  • FROM is the base domain to match for the request to be proxied.
  • TO... are the destination endpoints to proxy to. The number of upstreams is limited to 15.

Multiple upstreams are randomized (see policy) on first use. When a proxy returns an error the next upstream in the list is tried.

Extra knobs are available with an expanded syntax:

dohproxy FROM TO... {
    except IGNORED_NAMES...
    tls CERT KEY CA
    tls_servername NAME
    policy random|round_robin|sequential
}
  • FROM and TO... as above.

  • IGNORED_NAMES in except is a space-separated list of domains to exclude from proxying. Requests that match none of these names will be passed through.

  • tls CERT KEY CA define the TLS properties for TLS connection. From 0 to 3 arguments can be provided with the meaning as described below

    • tls - no client authentication is used, and the system CAs are used to verify the server certificate (by default)
    • tls CA - no client authentication is used, and the file CA is used to verify the server certificate
    • tls CERT KEY - client authentication is used with the specified cert/key pair. The server certificate is verified with the system CAs
    • tls CERT KEY CA - client authentication is used with the specified cert/key pair. The server certificate is verified using the specified CA file
  • policy specifies the policy to use for selecting upstream servers. The default is random.

Metrics

If monitoring is enabled via the prometheus plugin, the following metrics are exported:

  • coredns_dohproxy_request_duration_seconds{to} - duration per upstream interaction.
  • coredns_dohproxy_requests_total{to} - query count per upstream.
  • coredns_dohproxy_responses_total{to, rcode} - count of RCODEs per upstream.

Examples

Proxy all requests within example.org. to a DoH nameserver:

example.org {
    dohproxy . cloudflare-dns.com/dns-query
}

Forward everything except requests to example.org

. {
    dohproxy . dns.quad9.net/dns-query {
        except example.org
    }
}

Load balance all requests between multiple upstreams

. {
    dohproxy . dns.quad9.net/dns-query cloudflare-dns.com:443/dns-query dns.google/dns-query
}

Internal DoH server:

. {
    dohproxy . 10.0.0.10:853/dns-query {
      tls ca.crt
      tls_servername internal.domain
    }
}

Documentation

Overview

Package https implements a plugin that performs DNS-over-HTTPS proxying.

See: RFC 8484 (https://tools.ietf.org/html/rfc8484)

Index

Constants

This section is empty.

Variables

View Source
var (
	RequestCount = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: pluginName,
		Name:      "requests_total",
		Help:      "Counter of requests made per upstream.",
	}, []string{"to"})
	RcodeCount = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: pluginName,
		Name:      "responses_total",
		Help:      "Counter of requests made per upstream.",
	}, []string{"rcode", "to"})
	RequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: plugin.Namespace,
		Subsystem: pluginName,
		Name:      "request_duration_seconds",
		Buckets:   plugin.TimeBuckets,
		Help:      "Histogram of the time each request took.",
	}, []string{"to"})
)

Variables declared for monitoring.

Functions

This section is empty.

Types

type HTTPS

type HTTPS struct {
	Next plugin.Handler
	// contains filtered or unexported fields
}

HTTPS represents a plugin instance that can proxy requests to another (DNS) server via DoH protocol. It has a list of proxies each representing one upstream proxy

func (*HTTPS) Name

func (*HTTPS) Name() string

Name implements plugin.Handler.

func (*HTTPS) ServeDNS

func (h *HTTPS) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (status int, err error)

ServeDNS implements plugin.Handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址