帅帅男孩 发表于 2019-1-1 14:14:55

使用haproxy 实现 http/ssh/mstsc复用

  网上较多HTTP/SSH复用,但实际环境中,使用HAPROXY做IIS负载均衡时,还需要使用80端口来使用远程桌面管理服务器。
  近日通过Wireshark抓包,找到了TPKT的报头字段,终于成功实现RDP协议复用:

  注:通常RDP使用TPKT作为其传输协议,TPKT运行在TCP之上。 当用于传输RDP时,使用的TCP端口是3389,而不是正常的TPKT端口102。
  参考文献:
  http://blog.csdn.net/kevin_bobolkevin/article/details/50790967
  TPKT通讯说明

  https://wenku.baidu.com/view/9f509844e2bd960591c67723.html
  

https://s4.运维网.com/wyfs02/M00/9A/BF/wKiom1laCESgVrh0AANwJnBcOd4329.png-wh_500x0-wm_3-wmp_4-s_2573990352.png

  

  最终配置文件如下,供参考:
  ------------------------------------------------------
  

  global
  daemon
  user haproxy
  group haproxy
  maxconn 49985
  log 127.0.0.1 local0
  log 127.0.0.1 local1 notice
  # tune.ssl.default-dh-param 2048
  

  defaults
  mode tcp
  log global
  log 127.0.0.1 local0 err
  

  option tcplog
  option dontlog-normal
  

  timeout connect    10s
  timeout queue      30s
  timeout client   15m
  timeout client-fin 15m
  timeout server   15m
  timeout tunnel   12h
  

  listen monitor
  bind *:8888
  #监听端口
  mode http
  #http的7层模式
  log global
  log 127.0.0.1 local0 err
  

  maxconn 5
  

  option httplog
  

  stats enable
  stats uri /
  stats refresh 15s
  

  timeout connect    10s
  timeout queue      30s
  timeout client   30s
  timeout server   30s
  

  listen http
  bind *:80
  maxconn 800
  timeout client 1h
  tcp-request inspect-delay 2s
  acl is_http req.payload(0,3) -m bin 474554 504f53 505554 44454c
  acl is_ssh req.payload(0,3) -m bin 535348
  acl is_rdp req.payload(0,3) -m bin 030000
  tcp-request content accept if is_http
  # use_backend http if is_http
  use_backend ssh if is_ssh
  use_backend rdp if is_rdp
  #监听端口
  option tcpka
  #是否允许客户端发送tcp keepalive 包,这个和http 的keepalive 没有关系
  #option redispatch
  #是否允许失败后重新分配session这个设置会存在返回的K/3CLOUD系统的session id变化导致闪退。可能的原因服务端有异常或者传输出现了异常
  option abortonclose
  #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接
  #tcp-request inspect-delay 30s
  

  hash-type consistent
  balance roundrobin
  stick-table type ip size 10240k expire 24h
  stick on src
  server server01192.168.90.121:80weight 100check agent-check agent-port 3333 minconn 0 maxconn 250 on-marked-down shutdown-sessions
  server server02192.168.90.122:80weight 100check agent-check agent-port 3333 minconn 0 maxconn 250 on-marked-down shutdown-sessions
  

  backend ssh
  mode tcp
  timeout server 1h
  server server-ssh 192.168.90.126:22
  

  backend rdp
  mode tcp
  timeout server 1h
  server server-mstsc 192.168.90.121:3389
  




页: [1]
查看完整版本: 使用haproxy 实现 http/ssh/mstsc复用