首页 > 其他 > 详细

nginx stream

时间:2020-03-29 22:20:03      阅读:65      评论:0      收藏:0      [点我收藏+]

 

4.修改配置文件

vim /opt/nginx/conf/nginx.conf(在配置文件最后行添加如下)
    stream {
      upstream NAME1 {
        hash $remote_addr consistent;
        server 10.22.0.7:5000 max_fails=3 fail_timeout=30s;
        server 10.22.0.8:5000 max_fails=3 fail_timeout=30s;
      }
      upstream NAME2 {
        hash $remote_addr consistent;
        server 192.168.5.8:8080 max_fails=3 fail_timeout=30s;
      }
      server{
      listen 8080;
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass NAME1;
      }
      server{
      listen 60000;
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass NAME2;
      }
    }
解析:

如上配置文件的含义为
将端口8080反向代理NAME1组的serverIP:PORT,最大失败次数为3,超时时间为30秒;
将端口60000反向代理NAME2组的serverIP:PORT,最大失败次数为3,超时时间为30秒。



作者:辉耀辉耀
链接:https://www.jianshu.com/p/5dcd1e027e17
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

nginx stream

原文:https://www.cnblogs.com/agang-php/p/12595039.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!