DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
proxy_protocol.h File Reference

HAProxy PROXY protocol codec (DETWS_ENABLE_PROXY_PROTOCOL) - zero-heap parser + builder for the v1 (text) and v2 (binary) headers a load balancer / proxy prepends, so the server can recover the real client IPv4 when it sits behind one. More...

#include "ServerConfig.h"

Go to the source code of this file.

Detailed Description

HAProxy PROXY protocol codec (DETWS_ENABLE_PROXY_PROTOCOL) - zero-heap parser + builder for the v1 (text) and v2 (binary) headers a load balancer / proxy prepends, so the server can recover the real client IPv4 when it sits behind one.

The header is sent once, before the proxied stream:

  • v1 (text): PROXY TCP4 <src-ip> <dst-ip> <src-port> <dst-port>\r\n (space-separated, CRLF-terminated; also PROXY TCP6 ... and PROXY UNKNOWN\r\n).
  • v2 (binary): a 12-octet signature, then ver_cmd (high nibble version 2, low nibble command - 0x1 PROXY / 0x0 LOCAL), fam (high nibble address family - 0x1 AF_INET, low nibble transport - 0x1 STREAM), a 2-octet big-endian address-block length, then the address block (for TCP/IPv4: src(4) dst(4) src-port(2) dst-port(2), network order).

This codec handles TCP/IPv4 (the library's address family); IPv6 / UNIX / LOCAL headers parse to their length but yield no addresses. Format per the HAProxy PROXY protocol spec.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file proxy_protocol.h.