GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

✨ GOLF(2gg) β€” connect-haproxy-tcp-socket ✨

okay bestie, welcome to the Golf docs, web-servers edition πŸ’– this is section 2gg of the Golf manual and we're about to make your Golf app and HAProxy hold hands, fr fr 🫢


🌸 NAME 🌸

connect-haproxy-tcp-socket β€” Golf documentation (web-servers)


πŸ’… DESCRIPTION πŸ’…

So here's the tea: this page shows you how to connect your application β€” the one listening on TCP port <port number> (and that you started with the -p option in mgrg) β€” to an HAProxy load balancer. periodt.

One use of HAProxy is to balance the load between different web servers, which in turn are connected to your Golf applications. In that setup, HAProxy does not directly communicate with your Golf applications (they're sitting behind other web servers, lowkey hiding).

But when you do want HAProxy to directly communicate with your Golf application servers? πŸ‘€ You may use a configuration similar to this one. What you're seeing is just a bare-bone setup needed to accomplish the goal β€” note the sections frontend, fcgi-app and backend, those are the relevant-to-Golf girlies. The HAProxy configuration file is typically in /etc/haproxy/haproxy.cfg:

global
    user haproxy
    group haproxy
    daemon

defaults
    mode    http
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend front_server
    mode http
    bind *:90
    use_backend backend_servers if { path_reg -i ^.*\/<your golf app name>\/.*$ }
    option forwardfor

fcgi-app golf-fcgi
    log-stderr global
    docroot /var/lib/gg/<your golf app name>/app
    path-info ^.+(/<your golf app name>)(/.+)$

backend backend_servers
    mode http
    filter fcgi-app golf-fcgi
    use-fcgi-app golf-fcgi
    server s1 127.0.0.1:3000 proto fcgi

Then restart HAProxy, she needs her beauty sleep cycle πŸ”„:

sudo systemctl restart haproxy

Quick note on the vibes here: the Golf application path is /<your golf app name> (and yes, the application name may or may not be the same β€” see request). The TCP port of the application is 3000 (could be any port number you choose that's greater than 1000 and lower than 65535). so basically, pick your fave πŸ’…

Now, HAProxy itself is bound to port 90 in this example (peep the frontend section above), and path_reg specifies which URLs will be passed to your Golf application β€” i.e. they must have /<your golf app name>/ in the URL. Meanwhile path-info specifies SCRIPT_NAME and PATH_INFO (as () regular sub-expressions), which are as such passed to your Golf application. And docroot is set to the application home directory (see directories) in case you wish to serve HTML documents from it β€” however, if you keep sensitive data there, specify another directory. 🚨 no cap, don't be leaving your secrets out in the open, bestie.

Your Golf application (named <your golf app name>) would have been started with β€” using the same application name <your golf app name> and TCP port 3000:

mgrg -p 3000 <your golf app name>

And now?? You should be able to connect and load-balance your Golf application servers directly from HAProxy. In this example HAProxy listens on port 90, so you'd refer to it with https://your-web-server:90/<your golf app name>/.... iconic. she's serving. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

  • Web servers

then the whole friend group:

  • connect-apache-tcp-socket
  • connect-apache-unix-socket
  • connect-haproxy-tcp-socket
  • connect-nginx-tcp-socket
  • connect-nginx-unix-socket
  • See all documentation

πŸŽ€ that's the whole page, bestie! go forth and load-balance responsibly πŸ’–

and a lil sign-off to close us out: this was page $VERSION of the Golf manual, dated $DATE β€” slay βœ¨πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from