An HTTP listener — also called a "listener socket" or "HTTP network listener" — is a networking component that routes incoming HTTP client requests to specific (often virtual) servers. The listener is assigned an IP address, port number, default server, and server name. This combination must be unique. 

Some web servers, however, allow multiple listeners on the same IP and port combo with unique host names. They simply choose which to use via the TLS SNI header — only producing one listener on the port at the kernel level.

An HTTP listener can also listen on all IP addresses on a specific port to capture and route all relevant traffic for a given machine. Similarly, you can establish multiple HTTP listeners that share an IP address but listen on various ports. The configuration of each machine will also influence whether it responds to different IP addresses. 

A listener is ultimately a software-based process, and requires resources to operate. It alerts the system kernel that an application wants to accept network traffic at the configured address(es). This packet monitoring happens at the OS level and supports traffic filtering using the Berkeley Packet Filter (BPF) and the IPTables utility. For example, you can configure the listener to ignore or block these requests based on your system settings.

Why are HTTP listeners useful?

Listeners instruct the kernel to alert user-space applications to connection requests using configured IP addresses and ports. This is especially important while using intermediary infrastructure components — such as load balancers and reverse proxies. Without a listener, these components cannot receive and pass HTTP traffic from clients attempting connections to services. 

HTTP listeners also run in a way that consumes minimal resources. Instead of polling frequently according to a predefined time interval, these tasks are event-driven. A listener will only respond when a connection (SYN) packet arrives on a configured network interface. They leverage the machine's native networking stack and hardware to process incoming packets. Accordingly, a hardware component called a network interface controller (NIC) can serve as a first-line detection layer for incoming requests. 

Plus, HTTPS listeners can help offload encryption and decryption to the load balancer to keep applications running efficiently.

Does HAProxy support HTTP listeners?

Yes! HAProxy products can use listeners to watch for incoming traffic from client devices before passing it onward. Plus, HAProxy compiles listener metrics to help you monitor current listener sessions, max sessions, bytes in, bytes out, denials, and overall status. 

To learn more about listeners in HAProxy, check out our Configuration Manual.