新版nginx已支持tcp及udp 的负载均衡

1.9.13版本开始
配置文件写法如下 代理squid 的3128端口和 dns UDP 53

stream { upstream squid { server 192.168.10.10:3128 weight=5; server 192.168.10.11:3128 max_fails=3 fail_timeout=30s; server 192.168.10.12:3128; }

upstream dns { server 192.168.10.1:53; server 192.168.10.2:53; }

  server {
    listen 3128;
    proxy_connect_timeout 1s;
    proxy_timeout 3s;
    proxy_pass bind;
} 

  server {
    listen 53 udp;
    proxy_responses 1;
    proxy_timeout 20s;
    proxy_pass dns;
} }