Skip to content

ExtractClientIpOptions

Defined in: packages/gateway/src/utils/ip.ts:16

Options for extractClientIp.

optional fallbackAddress?: string

Defined in: packages/gateway/src/utils/ip.ts:40

Fallback IP address used when no headers match (e.g., the socket remote address from the Node.js HTTP server). This is checked after all configured headers have been exhausted.


optional ipHeaders?: readonly string[]

Defined in: packages/gateway/src/utils/ip.ts:18

Ordered list of headers to inspect. Default: [“cf-connecting-ip”, “x-forwarded-for”].


optional trustedProxies?: readonly string[]

Defined in: packages/gateway/src/utils/ip.ts:28

List of trusted proxy IP ranges (CIDR notation). When specified, X-Forwarded-For will only be trusted if the rightmost IP (the most recent proxy) is within one of these ranges.

// Only trust X-Forwarded-For from Cloudflare IPs
{ ipHeaders: ["cf-connecting-ip", "x-forwarded-for"], trustedProxies: ["173.245.48.0/20"] }

optional useRightmostForwardedIp?: boolean

Defined in: packages/gateway/src/utils/ip.ts:34

When true, use the rightmost IP from X-Forwarded-For instead of leftmost. The rightmost IP is the one added by the most recent trusted proxy. Default: false.