Solved BungeeCord with HAProxy... Is that possible ?

Discussion in 'BungeeCord Help' started by CallMeGhosty, Aug 1, 2018.

  1. I want to use a HAProxy to check which lobby is the most available when a player connects through the BungeeCord. I tried a lot of ways ( changing bungee's config.yml, changing etc/haproxy/haproxy.cfg from the ubuntu server ), but everytime I tried to connect it kicked me for "Disconnected" and nothing showing in the logs.

    Currently, I am running:

    1 HAProxy -->
    • On a virtual machine ( at least trying to =]] )

    1 BungeeCord Proxy -->
    • 1 single plugin ( BungeeAuthMeBridge ),
    • 0 modules
    • Only edited the config.yml
    • Running on port 25565

    2 Lobbies -->
    • They are exactly the same, excepting the port being different
    • Spigot 1.12.2
    • 3 plugins ( ServerSelectorX, AuthMe & AuthMeBridge )
    • The first lobby is running on port 25567
    • The second one is running on port 25569.

    1 Gamemode -->
    • Survival in BungeeCord's config.yml
    • It's just an fresh, automatically generated world
    • No plugins
    • I named it Survival because I wanted to test ServerSelectorX.

    Note: All servers / proxies are running on localhost!

    I don't know what should I put in haproxy.cfg, I looked on the internet, but there's no haproxy.cfg ( at least an explanation about it ) for Minecraft Servers... Don't understand me wrong, I know how to configure Minecraft Servers, but HAProxy gives me headaches..

    So I just need a haproxy.cfg and maybe some things changed in bungee's config.yml ( like proxy_protocol ).

    Thanks for reading.
     
  2. MiniDigger

    Supporter

    while never having used haproxy myself before, I don't see why this shouldn't be possible.
    having quickly glanced at the docs, smth like this should do the trick:
    Code (Text):

    #Load balancer stats page access at hostname:8080/haproxy_stats
    listen stats <load_balancer_hostname>:8080
        mode http
        log global
        stats enable
        stats realm Haproxy\ Statistics
        stats uri /haproxy_stats
        stats hide-version
        stats auth admin:[email protected]

    frontend bungee_frontend
        bind *:25565
        mode tcp
        option tcplog
        timeout client  1m   # miiiiigghht want to play with those, no clue
        default_backend bungee_backend

    backend bungee_backend
        mode tcp
        option tcplog
        option log-health-checks
        log global
        balance roundrobin
        timeout connect 10s
        timeout server 1m   # again, if you notice random disconnects, play with those values
        server bungee1 <bungee 1 hostname>:<bungee 1 port> check
        server bungee2 <bungee 2 hostname>:<bungee 1 port> check
    if you notice random disconnects, play with the timeouts.
    might also need to play with the enabled options (I think the way I configured it it will show a hell lot of logs) and if you don't need it you can disable the stats listener
     
    • Useful Useful x 1
  3. md_5

    Administrator Developer

    HAProxy is redundant in virtually every use case - as mentioned on GitHub you should just use Bungee alone with plugins to pick servers
     
    • Winner Winner x 1
  4. @MiniDigger Thanks for the code.
    Should BungeeCord be on another port than the default one ( 25565 ) and let HAProxy be on 25565? I think so...

    - Running HAProxy on 25565
    - One lobby on 25567
    - Another lobby on 25569
    - Survival on 25571
    - BungeeCord on 25573

    Deleted the stats listener because I dont need it, and changed the backend a bit.

    Code (Text):
    frontend bungee_frontend
        bind *:25565
        mode tcp
        option tcplog
        timeout client 1m
        default_backend bungee_backend

    backend bungee_backend
        mode tcp
        option tcplog
        option log-health-checks
        log global
        balance roundrobin
        timeout connect 10s
        timeout server 1m
        server bungee1 127.0.0.1:25573 check
    I assumed that the name being "bungee1" it should be the port of the BungeeCord ( not mentioned the hostname, because I am running all servers / proxies on localhost ).
    However, if I do this, I didn't make anything, because the HAProxy lets BungeeCord decide which lobby to send the player in, looking in the priorities.
    Code (YAML):
    priorities:
     - lobby_one
      - lobby_two
    If I change the last line of the backend to these lines:
    Code (Text):
    server bungee1 127.0.0.1:25567 check
    server bungee2 127.0.0.1:25569 check
    It works, but BungeeCord can't see the players connecting to lobbies / gamemodes.
    Even if I do /glist showall in Console while I'm logged on one of the lobbies BungeeCord can't see me, because I'm connecting to the HAProxy, and it redirects me on one of the lobbies, without letting Bungee know.
    >glist showall
    13:34:31 [INFO] CONSOLE executed command: /glist showall
    13:34:31 [INFO] [lobby_one] (0):
    13:34:31 [INFO] [lobby_two] (0):
    13:34:31 [INFO] [survival] (0):

    I think the correct syntax is:
    1. People conect to default port ( which should be taken by BungeeCord )
    2. BungeeCord tells HAProxy to check for the most available lobby
    3. HAProxy replies to the BungeeCord and it ( Bungee ) sends the player to the most available lobby, or if possible, HAProxy does it.

    But I think that's impossible....

    Any ideeas ?

    Thanks again!
     
  5. MiniDigger

    Supporter

  6. You didn't understand. I DON'T want BungeeCord ( or BungeeCords ) behind HAProxy ( I already kinda knowed how to do that, it's pretty straight-forward ).
    I want HAProxy behind BungeeCord, and I don't want any "random distributing players between lobbies" plugins.
    Gonna have a look on: https://github.com/MinelinkNetwork/BungeeProxy and I will come later with a response.

    Edit: Where should I put the BungeeProxy files ? ( link ^^ )

    Edit two : I heard BungeeProxy is deprecated since newer BungeeCords are coming with the proxy_protocol option in config.yml. Still not sure how should I use that option.
     
    #6 CallMeGhosty, Aug 1, 2018
    Last edited: Aug 2, 2018
    • Useful Useful x 1
  7. Does anyone know if it's possible to connect the clients that are in a bungee when a bungee goes down that the players will be connected to one of the other bungee cords provided at proxy?
     
  8. Bump. I'm really curious as to if you can switch servers with HAProxy.