找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 21648|回复: 61

OpenWRT上使用haproxy对s-s做负载均衡

  [复制链接]
发表于 2016-3-14 14:19 | 显示全部楼层 |阅读模式
本帖最后由 丰花 于 2016-3-18 18:25 编辑

教程参考自:https://blog.chionlab.moe/2016/0 ... ize-s-s-on-openwrt/说是参考,其实跟照搬差不多了。

安装和配置haproxy:
openwrt软件源里应该是有haproxy的,直接 opkg install haproxy  就可以。
配置:
1、修改haproxy配置文件:/etc/haproxy.cfg,内容如下:


  1. global
  2.     log         127.0.0.1 local2

  3.     chroot      /root
  4.     pidfile     /tmp/haproxy.pid
  5.     maxconn     4000
  6.     user        root
  7.     daemon

  8. defaults
  9.     mode                    tcp    #TCP模式
  10.     log                     global
  11.     option                  tcplog
  12.     option                  dontlognull
  13.     option http-server-close
  14.     option forwardfor       except 127.0.0.0/8
  15.     option                  redispatch
  16.     retries                 2
  17.     timeout http-request    10s
  18.     timeout queue           1m
  19.     timeout connect         2s     #上游TCP服务器连接等待时间                                      
  20.     timeout client          1m
  21.     timeout server          1m
  22.     timeout http-keep-alive 10s
  23.     timeout check           10s
  24.     maxconn                 3000

  25. listen test1
  26.     bind 0.0.0.0:8388       #haproxy监听端口
  27.     mode tcp
  28.     server s1 X.X.X.X:8388
  29.     server s2 X.X.X.X:8389
  30.     server s3 X.X.X.X:8390
  31.     server s4 X.X.X.X:8391
复制代码
其中,X.X.X.X为ss服务器,8388~8391这四个端口都为ss服务器上运行ssserver的端口(如果觉得不够你可以再加几个)。haproxy监听的端口为8388。


然后使其生效:
1
# /etc/init.d/haproxy enable  #开机启动haproxy
# /etc/init.d/haproxy start   #启动haproxy



s-s配置:


s-s的udp应该是用不了了,所以就不要勾选下面的udp转发了。
填完后 保存&应用


最后的效果图:




ps:1、上面参考教程的地址打开会显示404,原因是s-s这个单词被替换了。。。
      2、s-s服务的加密方式和密码应保持一致。
本人也是小白,如有说不对的地方请轻拍。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
发表于 2016-3-14 14:42 | 显示全部楼层
学习学习。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 14:47 | 显示全部楼层
进来学习,
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 14:52 | 显示全部楼层
谢谢分享//。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 14:54 | 显示全部楼层
上来学习了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 15:05 来自手机 | 显示全部楼层
为什么要隐藏???????

点评

不隐藏的话,沉得太快,等过几天再设置不隐藏  发表于 2016-3-14 16:38
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 16:33 来自手机 | 显示全部楼层
不知效果怎么样

点评

我也是刚用上,还不知道效果怎么样,不过很明显的就是:haproxy上设置的服务器不相同的话,ip容易乱跳,对于某些对ip有要求的服务可能会不太友好。  发表于 2016-3-14 16:41
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 16:46 | 显示全部楼层

学习学习。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 16:53 | 显示全部楼层
这是写的什么啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 16:58 来自手机 | 显示全部楼层
学习下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 16:59 | 显示全部楼层
ip乱跳你设置下权重就行
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 17:01 | 显示全部楼层
其实怎么说呢 haproxy做负载均衡效果不是很好,但是做ss的冗余还是不错的

点评

当某个美元server不通时(表现为haproxy的out数据为0, 但能ping通), haproxy不能判断此server是否正常。 有没有其它办法? 或者除了明月固件, 有没有多个主备切换的固件?  详情 回复 发表于 2017-11-16 22:15
server cn1 cn1.ssd.com:21110 weight 45 rise 2 fall 3 check inter 2000 server ali ali.node.com:21110 weight 200 rise 2 fall 3 check inter 2000 当server里的域名不存在时,出告警 haproxy -f hapr  详情 回复 发表于 2017-6-19 21:34
请问冗余是什么?  详情 回复 发表于 2016-3-14 17:51
据说cow不错,但是cow又不能搭建在路由器上  发表于 2016-3-14 17:22
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 17:16 | 显示全部楼层
看看
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 17:46 | 显示全部楼层
谢谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2016-3-14 17:50 来自手机 | 显示全部楼层
高大上的技能
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-19 21:49

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表