Setup a proxy server for a Minecraft server using HAPROXY


Setup a proxy server for a Minecraft server using HAPROXY

2020-11-29 19:56:25.283 +0000 UTC

When playing Minecraft with friends from all over the world, high latency and package loss can be some of the most annoying things.

However, if we can setup proxy servers that are close to the players and have good connection to the Minecraft server, we can mitigate this problem. To achieve such purpose, we can use HAPROXY on the proxy servers to redirect any connection to the proxy server to the Minecraft server.

First, we need to install HAPROXY on the proxy server.

yum install haproxy -y

Then edit the config file for HAPROXY.

vi /etc/haproxy/haproxy.cfg

Remove everything after the defaults section and add:

frontend haproxynode
    bind *:[proxy_port]
    mode tcp
    default_backend backendnodes

backend backendnodes
    server server1 [minecraft_ip]:[minecraft_port]

Change [proxy_port] [minecraft_ip] [minecraft_port] as you see fit.

Enable and start HAPROXY.

systemclt enable haproxy
systemclt start haproxy

At last, configurate the firewall to allow incoming connection to HAPROXY.