dnscrypt-proxy (v2.1.8) Multi-Scenario Configuration Guide: From Upstream Deployment to Downstream Integration
本文最后更新于 322 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
Article Abstract
To solve the intranet DNS pollution issue, an encrypted DNS relay solution is implemented by deploying dnscrypt-proxy. This tool supports DoH/DoH protocols and can be used as an upstream node (overseas VPS) or a downstream node (intranet LXC container), distinguishing roles and setting encrypted communication parameters through configuration files. In the actual deployment, a San Jose node is used as the encrypted upstream, and a downstream node is deployed in the home data center, utilizing Cloudflare Tunnel to hide the real IP and achieve split-tunneling for internal and external DNS queries. The solution balances lightweight design and security, managing encrypted connection parameters via stamp addresses to effectively bypass domestic DNS pollution while maintaining low system resource usage and high availability.
Qwen3-14B · 2026-06-18

1 Introduction

Actually, I have always wanted to build a stable, pollution-free DNS service in my local network, specifically to solve DNS pollution issues for certain applications that only need to resolve DNS pollution. For example, Emby's TMDB plugin cannot scrape movie and TV information properly simply because its API address ”api.themoviedb.org” is polluted by domestic DNS. For instance, here is the resolution result using domestic DNS:

image.png

Whereas the normal resolution should resolve to the AWS CloudFront Anycast address:

image.png

Therefore, these applications do not actually need a global proxy; all they need is a ”pollution-free” DNS.

In the past, to solve the DNS pollution issue, I relied on the built-in Clash plugin in the Merlin firmware on my AC86U router, hijacking UDP port 53 to forward DNS requests to an external encrypted DNS service. Although this method could also solve DNS pollution, it came with significant limitations:

  1. High requirements for service stability: Once the Clash plugin crashes or restarts, the DNS resolution of all intranet devices will be interrupted instantly. The impact is too broad, making it a highly coupled solution with an obvious single point of failure risk.
  2. Limited by the AC86U router: This solution heavily relies on a specific router model and its plugins. Currently, I am gradually promoting the ”de-router-centralization” of proxy-related functions in my home data center: for example, offloading main proxy tasks to the HTTP proxy provided by Shadowsocks on Apple TV (which can be directly used by some applications that support proxy settings), or combining it with redsocks2 deployed on LXC to implement a ”lightweight bypass gateway” function (for applications that do not support proxy settings; for the specific setup process, see the article:Home Data Center Series - Building a Lightweight Bypass Gateway Based on HTTP Proxy: redsocks2 + iptables Practical Guide), making it easier to replace hardware and manage centrally in the future: the AC86U may not necessarily be used in the future, and relying on it is clearly unsustainable.

Therefore, I now prefer a cleaner, decoupled solution. It just so happens that I purchased a Racknerd 1-core 1GB RAM VPS located at the San Jose node for $10.99/year to act as a jump server (Racknerd_Low-spec1_879), and it can open ports to the outside (it doesn't matter as a jump server, but the VPS at the Chicago node, which serves as my active-active disaster recovery node, will absolutely not open any ports). Therefore, the plan is as follows: spin up another LXC container or Docker instance in the home data center intranet to deploy a DNS downstream node, providing standard port 53 DNS services to intranet devices, and sending the received DNS requests in an encrypted format to the DNS upstream node in San Jose; deploy an encrypted DNS upstream node at the San Jose node, which can receive encrypted DNS requests from the DNS downstream node and forward them to well-known DNS providers like Cloudflare and Google for resolution, completely bypassing domestic DNS pollution.

Through this structure, we not only achieve decoupling and high availability, but if needed, we can also use the DNS downstream node to flexibly configure split-tunneling by domain name or IP—routing domestic requests through domestic DNS and foreign requests through the encrypted channel, achieving split-tunneling for domestic and international DNS queries.

However, how should the software for implementing DNS upstream nodes and DNS downstream nodes be chosen? After some investigation, it was found that the software dnscrypt-proxy can serve as the software choice for both upstream and downstream nodes.

2 Introduction to dnscrypt-proxy

dnscrypt-proxy is a powerful and highly customizable local DNS “relay” proxy tool that supports encryption, primarily used to protect privacy and integrity during DNS queries. Maintained by Frank Denis, it supports various modern DNS encryption protocols, including DNSCrypt v2 and DNS-over-HTTPS (DoH), and features flexible forwarding, filtering, and policy routing capabilities, making it one of the core components for building custom, secure DNS systems.

Compared to traditional plain-text DNS requests, the encryption protocols supported by dnscrypt-proxy can effectively prevent ISPs or man-in-the-middle attacks from monitoring and tampering with DNS queries. In addition, it has built-in support for multiple public DNS providers (such as Cloudflare, Quad9, NextDNS, etc.). Users can specify trusted upstreams by configuring the server_names parameter, or customize their own DoH servers.

dnscrypt-proxy supports listening on any local port (such as the standard port 53 or a custom port) and can securely forward received DNS queries to a remote encrypted DNS server. Combined with tools like dnsmasq or operating system DNS settings, it can provide privacy-protecting recursive resolution services for the entire network. It also features a built-in caching mechanism to improve query speeds and supports advanced features such as domain-based black/white list filtering, EDNS client subnet policies, and anonymous DNS relays.

In addition, although the configuration file of dnscrypt-proxy is highly structured, it is very flexible and suitable for fine-tuning in various environments. It can run on high-performance servers as an enterprise-grade DNS egress node, or be easily deployed on low-power devices (such as Raspberry Pi, small VPS, low-end VPS, etc.) as a lightweight home or personal DNS solution.

In summary, dnscrypt-proxy is an encrypted DNS proxy tool that balances performance, privacy, security, and flexible configuration capabilities. It is especially suitable for technical users seeking a ”pollution-free DNS” environment and is highly appropriate for scenarios requiring ”DNS request encryption,” making it an excellent software choice for both upstream and downstream DNS nodes.


Actually, besides dnscrypt-proxy, AdGuard Home could also meet my needs: it not only has built-in support for encrypted upstreams like DoH/DoQ, but also possesses relatively complete DNS policy management capabilities. However, I ultimately chose the lightweight dnscrypt-proxy for two main reasons:

First, my requirements are actually very simple. When used as DNS upstream node software, I only want it to forward the encrypted foreign domain query requests sent by the DNS downstream node to a clean, encrypted DNS upstream. When used as DNS downstream node software, I only need it to send the intranet devices' query requests for foreign domains to the DNS upstream node in an encrypted manner. I don't need AdGuard Home's heavy-duty features like ad blocking, graphical interface, and rule subscriptions at all. Rather than introducing a bunch of unused components that increase system burden, it is better to focus on the goal with the simplest and most reliable solution (though I might have taken this for granted, as I ultimately still chose AdGuard Home for the downstream node, for reasons I will explain later).

Secondly, the VPS at the San Jose node itself has poor performance, with tight memory and CPU resources, making it unrealistic to run a Web service like AdGuard Home that needs to be resident for a long time. On the other hand, dnscrypt-proxy is lighter and has lower resource usage, making it possible to run a long-term, stable, worry-free, and low-resource unpolluted DNS upstream node instead.


3 Installation of dnscrypt-proxy

1 Installation from Source

Since the dnscrypt-proxy version provided by apt is too low (still oldstable):

image.png

While the latest official version on GitHub is 2.1.8, released on March 27, 2025:
image.png

The version gap is indeed too large, and the key point is that the configuration logic of version 2.1.6 is quite different from previous versions (the most critical being the removal of the ”server = true/false“ misleading parameter), so I only recommend directly using the latest 2.1.8 version (dnscrypt-proxy official latest version download on GitHub), therefore only the source code installation method is shown:

# 进入工作目录
cd /opt

# 下载官方 release
wget https://github.com/DNSCrypt/dnscrypt-proxy/releases/download/2.1.8/dnscrypt-proxy-linux_x86_64-2.1.8.tar.gz

# 解压
tar -xzf dnscrypt-proxy-linux_x86_64-2.1.8.tar.gz
cd linux-x86_64

# 拷贝二进制文件到系统默认路径
cp dnscrypt-proxy /usr/local/bin/

# 基于官方模板创建配置文件(可选),后面我会直接提供最小化配置文件
mkdir -p /etc/dnscrypt-proxy
cp /opt/linux-x86_64/example-dnscrypt-proxy.toml /etc/dnscrypt-proxy/dnscrypt-proxy.toml

2 Deployment Using docker run Format

docker run --name dnscrypt-proxy -d --restart=always \
  -p 53:53/udp \
  -p 443:443/tcp \
  -p 443:443/udp
  -v /docker/dnscrypt-proxy:/config \
  -e TZ=Asia/Shanghai \
  klutchell/dnscrypt-proxy

# Download the official releasewget https://github.com/DNSCrypt/dnscrypt-proxy/releases/download/2.1.8/dnscrypt-proxy-linux_x86_64-2.1.8.tar.gz# Extract

4 dnscrypt-proxy.toml Configuration File

1 Clarifying the Working Mode and Deployment Location of dnscrypt-proxy

tar -xzf dnscrypt-proxy-linux_x86_64-2.1.8.tar.gzcd linux-x86_64:

Is it running in a local network, providing DNS forwarding services for intranet devices? Or is it deployed on a public network node, providing encrypted relay functions for multiple downstream clients?

In fact, no matter where it is deployed, dnscrypt-proxy alwayspossesses both capabilities at the same time:

  • It listens on one or more ports, receiving DNS requests from clients (which could be terminals or dnsmasq) (acting as a ”server”)
  • At the same time, it also forwards these requests to upstream DNS services (such as DoH, DNSCrypt servers, etc.) based on the configuration, and receives responses (acting as a ”client”)

This working mechanism of ”receiving requests at the frontend and forwarding queries at the backend” determines that dnscrypt-proxy is essentially aDNS relay proxy。

Therefore, we should not mechanically classify it as a Server or Client (which is how older versions did it, making it very confusing). A more accurate perspective is:Its deployment location + who its service target is。

For example:

  • dnscrypt-proxy deployed in a local network (downstream node), usually provides DNS services to intranet devices and acts as a local DNS relay. In this case, its upstream might be a DoH server, or even another dnscrypt-proxy deployed by yourself on a public network node (which is my current deployment scenario).

  • dnscrypt-proxy deployed on a public network node (upstream node), is more like a secure DNS transit station. It listens on TCP port 443 or UDP port 53 of a public IP address (if publishing DoH via Cloudflare Tunnel, it can be any local port), provides DNSCrypt or DoH services to the outside, and forwards requests to trusted upstream DNS services.

2 Examples of Common Deployment Scenarios

After clarifying the relay positioning of dnscrypt-proxy, we can choose different deployment methods and configuration combinations based on actual needs. Below are several typical scenarios, basically covering common usages such as local forwarding, remote relay, and server-side encryption protocol provisioning:

Scenario 1: Listening Port + Using Encrypted Upstream DNS (DoH/DNSCrypt client, suitable for downstream DNS nodes)

listen_addresses = ['0.0.0.0:53']

doh_servers = true
dnscrypt_servers = false

This configuration will listen on port 53 locally, receive DNS requests from local devices, and perform encrypted queries via DoH to trusted upstreams (such as Cloudflare, NextDNS, or self-built upstream nodes). It is suitable for deployment in a local network as an ”encrypted DNS relay”, just like the well-known slogan: ”We don't produce water, we are just nature's porters.” Of course, it needs to be modified here: ”I don't resolve domain names myself, I just forward the resolution results of other trusted upstream DNS to you.”

Scenario 2: Listening Port + Using System DNS (minimal dependency, suitable for offline/debugging)

listen_addresses = ['0.0.0.0:53']

doh_servers = false
dnscrypt_servers = false

Without relying on any external encryption protocols, dnscrypt-proxy will call the system's default resolver (usually configured in /etc/resolv.conf) to perform ordinary DNS queries.
Suitable for use as a lightweight DNS relay in debugging, restricted networks, or temporary offline environments.

However, this method does not provide any encryption capabilities and is vulnerable to pollution and hijacking, so it is not recommended for production environments.

Scenario 3: Listening Port + Providing Encryption Protocol Itself (DoH/DNSCrypt server, suitable as a self-built upstream DNS node)

# 可选,兼顾使用tailscale ip提供常规基于53端口的DNS服务
listen_addresses = ['tailscale IP:53']

# 开启 DoH 服务
[local_doh]
listen_addresses = ['你的公网IP:443']
path = '/dns-query'
cert_file = '/path/to/cert.pem'
cert_key_file = '/path/to/key.pem'

In this mode, dnscrypt-proxy is not just a DNS relay, but transforms into an ”encrypted DNS service provider”. For example, you can deploy it on an overseas node, use port 443 to provide DoH services to the outside, and use certificates generated by ACME to enable HTTPS. The intranet dnscrypt-proxy (downstream node) can access it through the public address, achieving an encrypted, obfuscated, and anti-interference DNS query channel.

You can even use Tailscale or a VPN to allow intranet devices to directly access its port 53 using regular DNS queries via private network addresses (provided that listen_address is correctly configured), achieving the simplest encrypted DNS queries.


There are two ways for downstream DNS nodes and upstream DNS nodes to communicate securely: DoH and DNSCrypt (v2). In my configuration in this article, DoH is used exclusively, and DNSCrypt (v2) is not used. This is because if DNSCrypt (v2) is to be used, the upstream DNS node must listen on a public IP and port, which requires ufw to allow access to the corresponding ports. This conflicts with my ”fully closed” security philosophy (never open any ports unless absolutely necessary). On the other hand, DoH can be used in conjunction with Cloudflare Tunnel, which is fully compatible with the ”fully closed” philosophy. Therefore, only DoH is used in this article, but this does not mean DNSCrypt is not good; everyone must understand this point.


3 Configuration Examples (Version 2.1.8)

3.1 Self-built Upstream DNS Node Configuration (Suitable for Overseas VPS Deployment)

Create a new configuration file:

vim /etc/dnscrypt-proxy/dnscrypt-proxy.toml

Then paste the following template containing the minimum usable configuration and save it:

# 主 DNS 监听地址(明文 DNS),可设为 0.0.0.0:53,但是不建议,这样就成公共DNS了,建议设置为tailscale IP
listen_addresses = ['tailscale IP:53'] 

# 指定使用哪些上游服务器的名称(来自 [sources] 列表),否则 dnscrypt-proxy 不会启用任何上游解析器
server_names = ['google', 'cloudflare'] 

# 用于自举解析上游服务器域名(如 DoH 地址)所用的传统 DNS 服务器
bootstrap_resolvers = ['1.1.1.1:53', '8.8.8.8:53']

# 网络连通性检测地址,启动前会测试是否能连通此 DNS
netprobe_address = '1.1.1.1:53'


# 本地提供 DoH 服务的设置,可作为私有 DoH 服务器使用
[local_doh]
# DoH 监听地址,需绑定在 443 端口
listen_addresses = ['公网IP:443']

# HTTP 路径,通常设为 /dns-query,但是为了防止被扫描,建议改个复杂的
path = '/dns-query'

# TLS 证书与私钥路径,建议使用有效证书(如Let's Encrypt),如果套cloudflare,也可以使用cloudflare自签证书
cert_file = '/etc/certs/dns.tangwudi.com/dns.tangwudi.com.crt'
cert_key_file = '/etc/certs/dns.tangwudi.com/dns.tangwudi.com.key'


# 远程服务器列表来源,用于动态加载支持的上游 DNS(支持 DNSCrypt 和 DoH)
[sources]

  ### DNSCrypt 项目的主服务器列表,包含数百个公开上游服务器
  [sources.public-resolvers]
  urls = [
    'https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/public-resolvers.md',
    'https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md'
  ]
  cache_file = 'public-resolvers.md'  # 本地缓存文件名
  minisign_key = 'RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3'  # 文件签名验证公钥
  refresh_delay = 73  # 多久更新一次列表(分钟)
  prefix = ''  # 前缀可用于标识该来源中的服务器名称

  ### 匿名中继服务器列表,用于构建 Anonymized DNS 查询链
  [sources.relays]
  urls = [
    'https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/relays.md',
    'https://download.dnscrypt.info/resolvers-list/v3/relays.md'
  ]
  cache_file = 'relays.md'
  minisign_key = 'RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3'
  refresh_delay = 73
  prefix = ''

# 针对某些上游 DNS 服务器的兼容性修正
[broken_implementations]

# 这些服务器存在 DNS 报文分片问题,会被标记处理或避免使用
fragments_blocked = [
  'cisco', 'cisco-ipv6', 'cisco-familyshield', 'cisco-familyshield-ipv6',
  'cisco-sandbox', 'cleanbrowsing-adult', 'cleanbrowsing-adult-ipv6',
  'cleanbrowsing-family', 'cleanbrowsing-family-ipv6',
  'cleanbrowsing-security', 'cleanbrowsing-security-ipv6'
]
  • listen_addresses = ['tailscale IP:53'] # Specifies the names of which upstream servers to use (from the [sources] list), otherwise dnscrypt-proxy will not enable any upstream resolversserver_names = ['google', 'cloudflare']
  • # Traditional DNS servers used for bootstrapping resolution of upstream server domain names (such as DoH addresses) bootstrap_resolvers = ['1.1.1.1:53', '8.8.8.8:53']

# Network connectivity probe address, will test if this DNS can be reached before starting # Specifies the names of which upstream servers to use (from the [sources] list), otherwise dnscrypt-proxy will not enable any upstream resolversnetprobe_address = '1.1.1.1:53' # Settings for providing local DoH service, can be used as a private DoH server [local_doh]

3.2 Downstream DNS Node Configuration

Create a new configuration file:

vim /etc/dnscrypt-proxy/dnscrypt-proxy.toml

Then paste the following template containing the minimum usable configuration and save it:

# 明文监听地址,使用内网IP
listen_addresses = ['192.168.x.x:53']

# 指定使用的远程上游 DNS 名称
server_names = ['sanjose-custom']  # 指向你上游节点的自定义名字

# 自举解析用的 DNS(首次解析上游节点 DoH 域名,国内的家宽就只能使用国内的域名服务器了)
bootstrap_resolvers = ['119.29.29.29:53', '223.5.5.5:53']

# 网络探测地址,可选但建议保留,避免启动失败,根据自己情况填写
netprobe_address = '119.29.29.29:53'

# 静态定义自建上游服务器(通过 DNS stamp)
[static.'sanjose-custom']
stamp = 'sdns://...'  # 你服务端生成的 stamp,含 DoH 地址及路径

3.3 Extended Knowledge: stamp Addresses

listen_addresses = ['Public IP:443']# HTTP path, usually set to /dns-query, but to prevent scanning, it is recommended to change to a complex onepath = '/dns-query'

  • # TLS certificate and private key paths, recommended to use a valid certificate (such as Let's Encrypt), if using Cloudflare, Cloudflare self-signed certificates can also be used
  • cert_file = '/etc/certs/dns.tangwudi.com/dns.tangwudi.com.crt'
  • cert_key_file = '/etc/certs/dns.tangwudi.com/dns.tangwudi.com.key'
  • # Remote server list sources, used to dynamically load supported upstream DNS (supports DNSCrypt and DoH)
  • [sources]
  • ### Main server list of the DNSCrypt project, containing hundreds of public upstream servers

A stamp is for downstream DNS clients (such as another dnscrypt-proxy) to use, to tell them: how to connect to me, via which protocol, using which address, at which path, and with which encryption key. Since a stamp is an unreadable string (a custom variant of base64 encoding), we usually need to use tools togenerate or decodeit.


Why is a Stamp needed?

In the early days, clients of the DNSCrypt protocol (v1) had to manually fill in a bunch of configuration items like IP address, port, public key, and path when connecting to an upstream server, which was not only tedious but also inconsistent. As more features were supported, such as DoH and anonymous relays, the configuration complexity increased further. To simplify this process, developers proposed Stamp the concept: packing all necessary information into a standardized string. This string can either be manually pasted or directly written into a .toml configuration file, making it a lightweight, universal, and easy-to-distribute connection description method.

Especially in the scenario where you build your own upstream DNS server,without a Stamp, you cannot add your own service node to the downstream dnscrypt-proxy configurationTherefore, once you have deployed DNSCrypt or DoH services on a VPS or home server, you must generate the corresponding stamp for it to function properly.


How to generate a stamp address? It's very simple, just use the official online tool provided by dnscrypt:Official online generation tool for stamp addresses。

image.png

The Hashes in the image above need to be generated based on the crt certificate used by the upstream node using the following command:

openssl x509 -in /path/to/your.crt -noout -pubkey \
  | openssl pkey -pubin -outform DER \
  | openssl dgst -sha256 -binary \
  | openssl enc -base64

For example, generating the Hashes value for my San Jose node:

image.png

5 Setting dnscrypt-proxy to Start on Boot as a Service (Source Installation)

Assuming you have completed the modification of the configuration file

Ensure that your dnscrypt-proxy.toml file is fully configured and dnscrypt-proxy can start normally. The test command is as follows:

/path/to/dnscrypt-proxy -config /path/to/dnscrypt-proxy.toml -check

If the test passes, the following information will be output:

image.png

**systemd service file installation (if you installed from source)

Create the systemd service file:

vim /etc/systemd/system/dnscrypt-proxy.service

Paste and save the following content:

[Unit]
Description=dnscrypt-proxy
After=network.target

[Service]
ExecStart=/usr/local/bin/dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml
Restart=on-failure
RestartSec=5
User=nobody
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

Reload systemd configuration and enable the service

systemctl daemon-reexec
systemctl daemon-reload
systemctl enable dnscrypt-proxy
systemctl start dnscrypt-proxy

Check running status

systemctl status dnscrypt-proxy

6 Afterword

Although dnscrypt-proxy can act as both an upstream and downstream DNS node, if you just want to deploy a downstream node at home to provide DNS resolution services for LAN devices, and do not particularly emphasize ”extreme lightweighting”, it may not be the most ideal choice.

An obvious problem is that when you use dnscrypt-proxy as a downstream client to connect to your self-built upstream node,you cannot directly fill in an HTTPS address like most DoH clients do(for example https://dns.tangwudi.com/dns-query): As described earlier in the article, you must first generate a dedicated ”stamp” address, which needs to include information such as the service's public IP, public key, port, and path. Precisely because the stamp must contain these fields, it requires the public IP of your public upstream server (and the port must also be open for access),which directly prevents you from hiding the node's real IP through Cloudflare's “orange cloud” (proxied) mode.

On the other hand, when using AdGuard Home, NextDNS, or system-level DoH support (such as Android, iOS, macOS) as downstream DNS nodes, you only need to fill in a standard HTTPS address. The advantages of this approach are:

  • Supports Cloudflare Proxy to hide the real IP of the upstream server, improving security and DDoS resilience;
  • No need to deal with the tedious process of generating and maintaining stamps;
  • Can be flexibly combined with services provided by Cloudflare, such as access control, security checks, and WAF;
  • It is more ”what you see is what you get” for users, with no complex formats or tool barriers.

From these perspectives, one of the biggest advantages of dnscrypt-proxy in downstream scenarios is probably that it is extremely lightweight with minimal dependencies (no UI, single binary, extremely low resource consumption),making it suitable for deployment in devices or containers with extremely limited resources, such as minimalist deployments in embedded systems, software routers, Raspberry Pi, etc. But this is clearly not the main constraint for most home users, especially when you already have alternatives like AdGuard Home or NextDNS that offer Web UIs and log management capabilities.

So this feels a bit ”upside down”: originally, dnscrypt-proxy's stamp mechanism was meant to standardize configuration and enhance security, which makes perfect sense when facing public upstream services. However, once you build your own upstream node as a user, it becomes an extra burden instead. Especially when you want to hide the real IP of the upstream server and proxy it through Cloudflare's CDN, the design of the stamp requiring the exposure of the public IP directly hinders your ability to apply a protective shield. Of course, dnscrypt-proxy as a downstream node is not entirely without advantages; one of its unique capabilities is:It can be used without relying on domain name resolution, establishing an encrypted connection based solely on IP, public key, and port, which is extremely valuable in certain special scenarios—for example, during periods when the GFW blocks SNI on a large scale, ordinary DoH services might be interrupted due to the inability to resolve domain names or TLS handshake failures, whereas the dnscrypt protocol can bypass these restrictions via hardcoded IP + Stamp, serving as a backup solution with ”anti-blocking” characteristics. This is something other downstream solutions based on the DoH protocol do not possess.

After some deliberation, I ultimately chose to run dnscrypt-proxy on a ”cheap VPS” in San Jose to build the DNS upstream node (and publish DoH via Cloudflare Tunnel); inside my home data center, I chose the already deployed AdGuard Home as the downstream node, using the DoH address to connect to the upstream node and providing traditional port 53 DNS resolution services for the entire local network. This maintains the flexibility and security of the upstream service while simplifying the downstream configuration and management burden, balancing ease of use and lightweighting.


When putting a self-hosted DoH service (such as one running on port 443 of dnscrypt-proxy) behind Cloudflare, different deployment methods will have a significant impact on the origin-pull behavior:

  • If your upstream node directly opened port 443, and Cloudflare uses the traditional public IP origin pull, then whether or not CDN (orange cloud) is enabled, the DoH service will usually work normally.
  • However, if your upstream node closes port 443 and you chooseCloudflare Tunnel as the origin pull method, and wish to expose the DoH service, you need to pay extra attention to several key configurations at this time:
  1. In the Tunnel service type, HTTPS should be selected;
  2. Be sure to set the ”Origin Server Name”, which will be sent to the local service as SNI (Server Name Indication). Otherwise, when using Cloudflare's default strict certificate validation mechanism (especially after enabling the orange cloud), the TLS handshake may fail;
  3. Depending on specific needs, you can also set “HTTP Host Header”, to ensure that the requests sent to the local service contain the correct Host header field. This is particularly critical for certain services that rely on virtual host configurations (such as Nginx or AdGuard Home).
    image.png

In other words, when you use Tunnel mode to expose a local DNS service based on HTTPS,“the ”Origin Server Name" is the core configuration item for whether Cloudflare Tunnel can successfully complete the origin pull: forget to configure it, and TLS is out of the question.


View Related Categories · 3 Matches
📌 Content Structure Prompt:
This content is part of the following knowledge map, where you can view the complete content path: Cloudflare Learning Map。
📎 Related Articles
Share this article
The blog content is original, please indicate the source when reposting! The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if needed, you can join theTelegram Groupto discuss questions together.

Comments

  1. Windows Chrome 86.0.4240.198
    2 years ago
    2025-5-22 3:10:53

    Written very detailed and specific!!! Awesome

    • Owner
      VIP Coupon Site
      Macintosh Chrome 136.0.0.0
      2 years ago
      2025-5-22 8:12:22

      For operations I usually do, some details are quickly forgotten. If I don't write them down in detail, I might not even understand them myself next time...

      • Tang Wudi
        Windows Chrome 86.0.4240.198
        2 years ago
        2025-5-22 14:11:21

        Yeah, sometimes it's just a problem with one of the steps that causes it, so it's better to record it in detail.

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗ
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Kaomoji
Emoji
Little Dinosaur
Flower!
Previous
Next
       

👋 Welcome to “Wudi's Personal Blog”

Here, long-term exploration is mainly carried out around the following directions:

🧱 Personal Digital Infrastructure and Blog System Construction
☁️ Cloudflare and Network Architecture Practice
🧠 AI and Knowledge System Exploration
🛡️ Network Security and Access Optimization
🎵 Music and Sound Cognition
👁️ Cognitive Perspectives and Worldviews