HAProxy vs Nginx – Differences in Reverse Proxy Mode

haproxyload balancingnginxreverse-proxy

What are the differences between HAProxy and Nginx when it comes to their abilities as a reverse proxy?

Best Answer

2019 update:

They are both stable and mature products. HAProxy is dedicated to load balancing and is better at that, whereas nginx is a webserver that can act as a load balancer.

Both:

  • HTTPS support
  • Websocket support
  • Stable, mature and very efficient products
  • Can handle 10k connections with minimal or no tuning

HAProxy:

  • TCP, TCP-SSL, HTTP and HTTPS load balancing
  • More flexibility on health checks and failover conditions
  • Basic caching (v1.8 - 2017)
  • Customizable log format, to import access logs to kibana/splunk/graylog
  • Detailed status page, to see active requests and servers status
  • Exportable metrics, to integrate with monitoring solutions (graphite/prometheus/datadog)
  • More high-performance oriented. Better indicated to handle 100k connections or 40 GbE interfaces.

Nginx:

  • HTTP and HTTPS load balancing (TCP - UDP in paid edition)
  • More flexibility on caching
  • Customizable log format, to import access logs to kibana/splunk/graylog
  • No status page (paid edition only)
  • No exportable metrics (paid edition only)
  • Can serve local files
  • Can serve FastCGI applications (not CGI)

HAProxy is a free software, fully open source. They make money by selling hardware appliance with HAProxy pre-installed.

Nginx is open core and many features are only available in the paid edition. Notably, it's lacking a status page and monitoring metrics that is a big NO NO to operate a load balancer.