40
votes

Hopefully a simple question. I apologize if this has been covered before. I'm learning haproxy and overall seems very straightforward and simple. However I am curious what the difference is between using frontend/backend and listen config blocks? My assumption is that listen is just simpler, for basic configurations, while frontend/backend is more advanced, allowing you to dynamically switch backends or share backends, etc. Is that it in a nutshell?

Thanks,

Al

1

1 Answers

43
votes

All three are called "proxies."

A listen is a combined frontend and backend. A listen has an implicit default_backend of itself, but the frontend logic of a listen can use other backends and its backend section can be used by other frontends. Fundamentally it just keep configuration more compact for simple rules, but otherwise it's almost the same as declaring a separate frontend and backend of the same name, while keeping the config together.

A "listen" section defines a complete proxy with its frontend and backend parts combined in one section. It is generally useful for TCP-only traffic.

http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4

It's paricularly useful for TCP because such configurations are usually simpler than HTTP. But a listen proxy can be used for either application.