Nginx stream(TCP/UDP)負載均衡


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;
    }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM