首页/Haproxy 四层代理

Haproxy 四层代理

1.安装

  1. #wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.22.tar.gz
  2. #tar zxvf haproxy-1.4.22.tar.gz
  3. #cd haproxy-1.4.22
  4. #uname -r
  5. #make TARGET=linux26 PREFIX=/usr/local/haproxy
  6. #make install PREFIX=/usr/local/haproxy
  7. #mkdir conf
  8. #/usr/local/haproxy/sbin/haproxy -f haproxy.cfg

haproxy.cfg配置

  1. ###########全局配置#########
  2. global
  3. chroot /usr/local/haproxy
  4. daemon
  5. nbproc 1
  6. group nobody
  7. user nobody
  8. pidfile /usr/local/haproxy/logs/haproxy.pid
  9. ulimit–n 65536
  10. #spread-checks 5m
  11. #stats timeout 5m
  12. #stats maxconn 100
  13. ########默认配置############
  14. defaults
  15. mode tcp #默认的模式mode { tcp|http|health },tcp是4层,http是7层,health只会返回OK
  16. retries 3 #两次连接失败就认为是服务器不可用,也可以通过后面设置
  17. option redispatch #当serverId对应的服务器挂掉后,强制定向到其他健康的服务器
  18. option abortonclose #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接
  19. maxconn 32000 #默认的最大连接数
  20. timeout connect 5000ms #连接超时
  21. timeout client 30000ms #客户端超时
  22. timeout server 30000ms #服务器超时
  23. #timeout check 2000 #心跳检测超时
  24. log 127.0.0.1 local0 err #[err warning info debug]
  25. ########smtp配置#################
  26. listen smtp 192.168.1.68:25
  27. # bind 0.0.0.0:25
  28. mode tcp
  29. balance roundrobin
  30. server s1 192.168.1.118:25 weight 1 maxconn 10000 check inter 10s
  31. server s2 192.168.1.240:25 weight 1 maxconn 10000 check inter 10s
  32. ########pop3配置#################
  33. listen pop3 192.168.1.68:110
  34. # bind 0.0.0.0:25
  35. mode tcp
  36. balance roundrobin
  37. server s1 192.168.1.118:110 weight 1 maxconn 10000 check inter 10s
  38. server s2 192.168.1.240:110 weight 1 maxconn 10000 check inter 10s
  39. ########imap配置#################
  40. listen imap 192.168.1.68:143
  41. # bind 0.0.0.0:25
  42. mode tcp
  43. balance roundrobin
  44. server s1 192.168.1.118:143 weight 1 maxconn 10000 check inter 10s
  45. server s2 192.168.1.240:143 weight 1 maxconn 10000 check inter 10s
  46. ########统计页面配置########
  47. listen admin_stats 192.168.1.68:8099
  48. # bind 0.0.0.0:8099 #监听端口
  49. mode http #http的7层模式
  50. option httplog #采用http日志格式
  51. #log 127.0.0.1 local0 err
  52. maxconn 5
  53. stats refresh 30s #统计页面自动刷新时间
  54. stats uri /stats #统计页面url
  55. stats realm XingCloud\ Haproxy #统计页面密码框上提示文本
  56. stats auth admin:admin #统计页面用户名和密码设置
  57. stats hide–version #隐藏统计页面上HAProxy的版本信息

监控图:

haproxy

SERVICE

相关服务与公开报价

以下为三家云市场官方店铺的在售商品,价格取自平台页面、可核验。 点击直达商品页,由平台完成下单与交付。

按本文主题推荐的云市场在售服务与公开报价
商品图 服务 / 商品 云市场 公开报价 操作
网站维护 Windows/Linux服务器维护 重装系统环境配置 杀毒木马 网站维护 Windows/Linux服务器维护 重装系统环境配置 杀毒木马 阿里云 ¥1000 去商品页
ECS云服务器环境配置服务 ECS云服务器环境配置服务 阿里云 ¥150 去商品页
Globalsign OV 企业型SSL证书 https证书申请配置 Globalsign OV 企业型SSL证书 https证书申请配置 阿里云 ¥3500 去商品页
HTTPS配置证书 Nginx证书配置 SSL配置 SSL证书配置 https配置 ssl证书 网站加密证书长期 CA证书 HTTPS配置证书 Nginx证书配置 SSL配置 SSL证书配置 https配置 ssl证书 网站加密证书长期 CA证书 腾讯云 ¥100 / 次 去商品页
CVM 磁盘扩容 | 数据盘分区挂载 | 本地磁盘迁移 CVM 磁盘扩容 | 数据盘分区挂载 | 本地磁盘迁移 腾讯云 ¥100 / 次 去商品页
Wordpress企业建站系统_官方中文站群版 Wordpress企业建站系统_官方中文站群版 腾讯云 ¥0 / 小时 去商品页
国密 SM2 证书安装服务 国密 SM2 证书安装服务 华为云 ¥300 / 次 去商品页
企业网站运维技术支持服务(年度订阅) 企业网站运维技术支持服务(年度订阅) 华为云 ¥6000 / 年 去商品页
SSL 证书安装配置服务(含证书过期更新) SSL 证书安装配置服务(含证书过期更新) 华为云 ¥100 / 次 去商品页
FREE CHECKUP

先做一次免费服务器体检

我们会在 1 个工作日内给出问题清单与处置建议 —— 做不做代维都没关系。

135 410 16684
工作日 Mon – Fri 10:00 – 22:00 · 紧急故障 7×24 响应
立即拨打
CONTACT

在线留言

有什么可以帮您?

带 * 为必填