nginx篇高级用法之基于TCP/UDP的四层调度

nginx 从1.9版本开始支持基于TCP/UDP的四层调度,在编译nginx时使用--with-stream开启该模块

支持TCP/UDP调度时,支持给所有的软件做调度器,例如:nfs smb ftp dns 等等...

在编译时:

./configure --with-http_ssl_module --with-stream

开启该模块

准备环境: 为了区分ftp1 和ftp2 他们各自放的共享内容不同

ftp1:192.168.2.100   /var/ftp/password

ftp2:192.168.2.200   /var/ftp/group

proxy:192.168.2.5    nginx

扫描二维码关注公众号,回复: 7422720 查看本文章

在nginx配置文件中进行编辑

events{

}

stream {

  upstream vsftp {
    server 192.168.2.100:21;   //后端服务器IP+代理端口
    server 192.168.2.200:21;
  }
  server {
    listem 21;   //本地监听端口,client访问端口

    proxy_connect_timeout 1s; //连接的超时时间,可选配置

    proxy_timeout 3s;

    proxy_pass vsftp;

  }
}

http{

}

测试结果正确

猜你喜欢

转载自www.cnblogs.com/lqinghua/p/11621353.html