HAProxy Configuration

Nice there is a PR for this :slightly_smiling_face:

I had just worked out a way to make this work with haproxy. I have each nginx instance set a SERVERID cookie, and use this haproxy backend

backend stick
  balance leastconn
  stick-table type string len 256 size 200k expire 120m peers haproxy

  # stick room name to server on initial connection
  # we will also store the SERVERID response cookie from this request (see below)
  stick on path,word(1,/) if { url_param(jwt) -m found }

  # stick/match room name to server on connection to xmpp endpoints
  # this refreshes the table entry during a conference as the endpoint is polled periodically
  stick on url_param(room) if { path_beg /xmpp-websocket } || { path_beg /http-bind }

  # match request cookie SERVERID on other requests, most importantly for the jvb websocket endpoint
  # we have to connect to the same server as our xmpp connection
  stick match req.cook(SERVERID)

  # store response cookie SERVERID
  # this sticks the user to this server until they join another room
  stick store-response res.cook(SERVERID)

  hash-type consistent
  timeout connect 5s
  timeout check 5s
  timeout client 30s
  timeout server 65s
  server shard1 x.x.x.x:443 maxconn 8192 check ssl verify none
  server shard2 x.x.x.x:443 maxconn 8192 check ssl verify none

Hi cwareen, the SERVERID cookie is also a good solution.
By the way my PR can’t be approved now because it will break websocket connection at the videobridge side.
Regards

Dear all , UDP 10000 is not routed by Haproxy … I’m using the Anthony_Garcia template, web interface works but audio/video no. Using tcpdump I cannot see requests for the UDP 10000. My Jitsi server is behind an Haproxy , the Haproxy is behind a firewall (NAT enabled).

Hey, thanks for sharing your solution. I am currently working out how HAProxy works.
I got two questions:

How/Where do you set the Cookie in the Jitsi nginx conf (Are you setting a header?) and could you share your whole HAProxy config? I got one HAProxy node and two Jitsi shards I want to route the traffic on but I am already desperating.

The cwareen HApoxy configuration is made for jitsi deployment using the jwt Auth mechanism.
The Serverid cookie is set at the response of the request containing the jwt URL parameter

The server cookie can also be set on at the XMPP connection creation if you’re using bosh connection but it won’t work if you’re using the XMPP over websocket configuration.

For our jitsi meet we’re setting a room name cookie at the client side on the jitsi client JavaScript (by using a custom base.html file) and we’re using this cookie for session stickiness.

Thanks for your answer. Are you able to share what you have done? I am currently setting up Jitsi as Non-Profit for the schools in my area which are not digitalized and we ran into problems because too many schools were using it. I already managed to setup autoscaling on aws, nevertheless at around 1000 users everything gets unstable.

I am also setting a cookie “serverid” now, but unfortunatly doesnt work. Any idea why? I am still landing on both servers when I want to join a specific room.

backend backendnodes
  balance leastconn
  #mode http
  stick-table type string len 256 size 200k expire 120m
  #stick on url_param(room) table backendnodes
  stick on url_param(room) if { path_beg /xmpp-websocket } || { path_beg /http-bind }
  stick match req.cook(SERVERID)
  stick store-response res.cook(SERVERID)

  hash-type consistent
  timeout connect 5s
  timeout check 5s
  timeout client 30s
  timeout server 65s
  server shard1 jitsi1dev.domain:443 maxconn 8192 check ssl verify none
  server shard2 jitsi2dev.domain:443 maxconn 8192 check ssl verify none

i will try the cookie approach tks