CLOUD CONCEPT

PROXY Protocol

PROXY Protocol is a connection-metadata format that lets a proxy or load balancer convey original client and destination information to a backend.

Cloud Concepts Hub →

What is PROXY Protocol

When a load balancer creates a separate connection to a backend, the backend may see the load balancer's address instead of the client's address. PROXY Protocol carries the original connection details ahead of application data, allowing compatible backends to use them for logging, access controls, and troubleshooting.

PROXY Protocol solves a common problem in proxied network architectures: the transport connection reaching an application does not necessarily identify the original client. A load balancer can accept a client connection and establish another connection to a target, making the load balancer appear to be the source. PROXY Protocol adds metadata describing the original connection, typically including source and destination addresses and ports. It conveys this information to the receiving application without changing the source address in the backend connection's IP packets.

The two main versions have different encodings. Version 1 uses a human-readable text line, while version 2 uses a binary header and supports optional type-length-value fields for additional metadata. For TCP connections, the sender places the header at the beginning of the backend connection, before application data. The receiver must explicitly support the version being sent and consume the header before handing the remaining bytes to its application-protocol parser.

For example, an organization might place a TCP load balancer in front of an NGINX or HAProxy fleet serving a custom application. If targets see only the load balancer's source address, client-based audit records and rate limits become misleading. Enabling PROXY Protocol on the load balancer and its backend listener lets the proxy recover the reported client address. The application or proxy must then be configured to use that recovered address rather than automatically treating the socket peer address as the end user.

In AWS, Network Load Balancer supports PROXY Protocol version 2 through the target-group attribute proxy_protocol_v2.enabled. Classic Load Balancer supports version 1 through a policy associated with the relevant backend ports for TCP or SSL listeners. Application Load Balancer instead provides HTTP client-address information through headers such as X-Forwarded-For; it does not provide PROXY Protocol support. For exam questions, distinguish the load balancer type, supported protocol version, backend compatibility, and whether native client IP preservation already meets the requirement.

PROXY Protocol is not an HTTP header and does not require HTTP inspection. With TLS passthrough over TCP, its header precedes the TLS ClientHello on the backend connection. The backend must therefore parse the PROXY header before starting TLS processing. Sending it to a listener that expects TLS or application data immediately commonly causes handshake failures or malformed-request errors. Conversely, a listener requiring the header can reject ordinary connections that omit it.

The metadata is not inherently authenticated or encrypted. Restrict access to PROXY-aware backend listeners to trusted senders, using appropriate security groups, firewall rules, and network isolation. Otherwise, a client that can connect directly may supply forged client-address information. The reported address also does not change what security groups or network ACLs observe in packet headers.

Validate health checks and application traffic separately during deployment. For Network Load Balancer, enabling version 2 also adds PROXY headers to health-check connections, but those headers do not carry client connection information. Finally, do not confuse this option with cross-zone load balancing, sticky sessions, or routing algorithms: those control traffic distribution, while PROXY Protocol communicates connection identity and metadata.

Key aspects of PROXY Protocol

PROXY Protocol preserves connection context across proxy boundaries through an explicitly supported metadata header that requires compatible receivers and a trusted network path.

Original connection metadata

Carries source and destination addressing information across a proxy boundary. Backends can use the reported client address even when their transport peer is the load balancer.

Version-specific encoding

Version 1 uses a text header; version 2 uses a binary header and can include additional type-length-value metadata. Configure the sender and receiver for compatible versions rather than assuming support for one implies support for both.

Explicit backend compatibility

The receiving listener must parse the header before processing application traffic or initiating its TLS handshake. Enabling the load-balancer option alone can break an otherwise healthy application.

Trusted-proxy boundary

The protocol does not authenticate the claimed client identity. Limit access to trusted proxies and ensure application access-control logic does not accept arbitrary client-supplied metadata.

Distinct from source IP preservation

PROXY Protocol conveys an address inside connection metadata rather than preserving it in the backend packet's source field. Application logs can use that metadata, but packet-level security rules still evaluate the actual network headers.

Independent load-balancing setting

This option does not select targets, provide session affinity, or distribute traffic across Availability Zones. Evaluate those settings independently and test health checks whenever changing header handling.

Cloud services for PROXY Protocol

A Network Load Balancer or Classic Load Balancer can forward traffic to applications or reverse proxies running on Amazon EC2 while adding original connection metadata. The load balancer determines the available protocol version: version 2 for Network Load Balancer and version 1 for Classic Load Balancer. The receiving software must parse that version before processing TLS or application data. Engineers should coordinate sender and receiver configuration, restrict direct backend access, verify that logs use the recovered client address, and test health checks separately from real client connections.

Amazon EC2 image Amazon EC2

EC2 instances can host PROXY-aware receivers such as HAProxy, NGINX, or compatible application servers behind a load balancer. EC2 itself does not parse the header; the software running on the instance must do so, and network controls should restrict access to trusted senders.

Open Amazon EC2 →