Skip to main content

Module proxy_protocol

Module proxy_protocol 

Source
Expand description

PROXY protocol v1/v2 parser for extracting the real client address from load balancers, CDNs, or other proxies that prepend the PROXY protocol header to TCP connections.

§Protocol overview

  • v1 (text): PROXY TCP4 192.168.1.1 192.168.1.2 12345 80\r\n
  • v2 (binary): 12-byte signature + version/command + family/transport + length + addresses

This module also provides PrefixedStream, a wrapper around TcpStream that prepends buffered bytes (the leftover data after the PROXY header) so the rest of the connection can be read normally.

Structs§

PrefixedStream
A wrapper around a TcpStream that prepends buffered bytes.
ProxyProtocolHeader
Parsed result of a PROXY protocol header.

Functions§

parse_proxy_protocol
Parse the PROXY protocol header from the beginning of a TCP stream.