我正在尝试在 nginx 后面运行不受约束的 DoH,但出现了 502 Bad Gateway 错误。
在 nginx 日志中我有以下消息:
2021/03/25 08:54:49 [error] 10052#10052: *1 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /dns-query?dns=AAABAAABAAAAAAABBXBlcmR1A2NvbQAAAQABAAApEAAAAIAAAAA HTTP/2.0", upstream: "https://10.0.159.133:443/dns-query?dns=AAABAAABAAAAAAABBXBlcmR1A2NvbQAAAQABAAApEAAAAIAAAAA", host: "127.0.0.1"
且不受约束仅表明:
[1616662996] unbound[28782:1] debug: comm point start listening 71 (30000 msec)
[1616662996] unbound[28782:1] debug: startlistening 71 mode r
[1616662996] unbound[28782:1] debug: SSL connection ip4 10.0.159.35 port 41552 (len 16)
[1616662996] unbound[28782:1] debug: comm_point_close of 71: event_del
[1616662996] unbound[28782:1] debug: close fd 71
我有以下 nginx 配置:
location /dns-query {
proxy_ssl_verify off;
proxy_pass https://unbound-host;
}
我错过了什么?
答案1
Unbound DoH 正在等待 HTTP/2 请求。但是 Nginx 代理模块不支持上游连接上的 HTTP/2。因此,您可以使用 grpc 代理:
location /dns-query {
grpc_pass grpc://unbound-host;
}
并在 unbound.conf 中禁用 DNS-over-HTTP 下游服务的 TLS:
http-notls-downstream: yes