标签:contain blog code pen nta user RKE 测试 img
原理实际行就是stream模式,因为nginx 支持基于stream 模式的lb同时支持(tcp.udp)以下是一个简单的配置
version: "3"
services:
lb:
image: openresty/openresty:alpine
volumes:
- "./nginx-lb.conf:/usr/local/openresty/nginx/conf/nginx.conf"
- "./dns.log:/var/log/nginx/dns.log"
ports:
- "53:53/udp"
- "53:53/tcp"
worker_processes 1;
user root;
events {
worker_connections 1024;
}
stream {
upstream dns_servers {
server 114.114.114.114:53;
server 8.8.8.8:53;
server 8.8.8.4:53;
}
server {
listen 53 udp;
listen 53; #tcp
proxy_pass dns_servers;
error_log /var/log/nginx/dns.log info;
}
}
docker-compose up -d
dig @127.0.0.1 baidu.com
效果
有点不太好的,默认的不支持health check,当然我们可以基于openresty 的stream 模块进行扩展,这样就可以更好的利用dns 做一些比较
强大的功能(比如coredns,consul)
https://www.nginx.com/blog/load-balancing-dns-traffic-nginx-plus/
https://github.com/StalkR/dns-reverse-proxy
标签:contain blog code pen nta user RKE 测试 img
原文地址:https://www.cnblogs.com/rongfengliang/p/13191689.html