码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx stream(TCP/UDP)负载均衡

时间:2016-12-15 09:30:57      阅读:491      评论:0      收藏:0      [点我收藏+]

标签:body   dev   dns   支持   work   ++   events   err   list   

Nginx-1.11.6编译安装


nginx编译安装,(平台:ubuntu 14.04);
sudo apt-get install zlib1g-dev
sudo apt-get install libpcre++-dev
sudo apt-get install openssl

然后configure: --with-stream 支持TCP/UDP负载均衡
cd nginx-1.11.6/
./configure --with-stream --prefix=/home/trait/nginx
make & make install

Nginx stream UDP负载均衡配置


nginx udp负载均衡配置:
root@trait:/home/trait/nginx/sbin# cat ../conf/nginx.conf

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

stream {
    
    upstream dns {
       server 192.168.111.99:10086;
       server 192.168.111.100:10086;
    }

    server {
        listen 192.168.111.98:10086 udp;
        proxy_responses 1;
        proxy_timeout 20s;
        proxy_bind $server_addr:$remote_port;
        proxy_pass dns;
    }
}

Nginx stream(TCP/UDP)负载均衡

标签:body   dev   dns   支持   work   ++   events   err   list   

原文地址:http://www.cnblogs.com/danxi/p/6181862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!