2017-09-08 183 views
0

我正在寻找haproxy(HAProxy版本1.5.18)配置,这将允许websocket负载平衡以及RabbitMQ负载平衡。我已经尝试了许多选择,但似乎没有工作,下面是我的HAProxy的配置文件:Haproxy Sockjs Websocket负载平衡和RabbitMQ负载平衡在相同的配置

global 
     log   127.0.0.1 local2 

     chroot  /var/lib/haproxy 
     pidfile  /var/run/haproxy.pid 
     maxconn  4000 
     user  haproxy 
     group  haproxy 
     daemon 

     stats socket /var/lib/haproxy/stats 

    defaults 
     mode     http 
     log      global 
     option     httplog 
     option     dontlognull 
     option http-server-close 
     option forwardfor  except 127.0.0.0/8 
     option     redispatch 
     retries     3 
     timeout http-request 15s 
     timeout queue   1m 
     timeout connect   10s 
     timeout client   1m 
     timeout server   1m 
     timeout http-keep-alive 10s 
     timeout check   10s 
     maxconn     3000 
     timeout tunnel   3600s 

    frontend http_web *:80 
     mode http 
     default_backend rgw 

    backend rgw 
     balance roundrobin 
     server rgw1 173.36.22.49:8080 maxconn 10000 weight 10 cookie rgw1 check 
     server rgw2 10.42.139.69:8080 maxconn 10000 weight 10 cookie rgw2 check 

    listen stats :9000 
     mode http 
     stats enable 
     stats realm Haproxy\ Statistics 
     stats uri /haproxy_stats # Stats URI 
     stats auth websocketadmin:websocketadmin 

    listen ampq 
     bind *:61613 
     mode tcp 
     option clitcpka 
     server rabbit1 10.42.6.112:61613 check inter 1s rise 3 fall 1 
     server rabbit2 10.42.6.113:61613 check inter 1s rise 3 fall 1 
     server rabbit3 10.42.6.114:61613 check inter 1s rise 3 fall 1 
     server rabbit4 10.42.6.115:61613 check inter 1s rise 3 fall 1 

HAProxy的不给任何错误,它打印下面的消息,但它不工作,我无法连接到websocket或连接到Rabbitmq。 但我一旦删除“listen ampq”,一切就开始正常工作。

Sep 8 21:00:40 localhost haproxy[3184]: Proxy http_web started. 
    Sep 8 21:00:40 localhost haproxy[3184]: Proxy rgw started. 
    Sep 8 21:00:40 localhost haproxy[3184]: Proxy stats started. 

回答

0

问题是端口61613,这是已经采取的另一种方法。所以我不得不改变一个新的端口并将其添加到防火墙规则中,现在它正在工作。