HACKER Q&A
📣 rvitorper

Why put a HAProxy in front of Nginx?


Hey, thanks for your time in advance.

I saw in a few comments people talking about having a HAProxy in front of a Nginx, which in turn acts as the reverse proxy to the app instances.

I wanted to understand what use-cases is this architecture viable and recommended, if you could just remove the HAProxy and have Nginx as the public facing server or maybe remove the Nginx altogether, and if there are other factors to use the HAProxy and the Nginx, such as pairing them with a few Varnish instances.

Thanks a lot for your time


  👤 theandrewbailey Accepted Answer ✓
HAProxy is primarily used as a load balancer. (HA = high availability) The feature sets of it and Nginx have lots of overlap (including reverse proxy), but HAProxy does not serve pages (aside from error pages), so you will need Nginx or another real webserver somewhere.

I use HAProxy to terminate TLS and HTTP/3, route to other webservers based on subdomain, and reverse proxy/cache. I'm 100% sure Nginx can do all that, though.