ExtractClientIpOptions
Defined in: packages/gateway/src/utils/ip.ts:16
Options for extractClientIp.
Properties
Section titled “Properties”fallbackAddress?
Section titled “fallbackAddress?”
optionalfallbackAddress?: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.
ipHeaders?
Section titled “ipHeaders?”
optionalipHeaders?: readonlystring[]
Defined in: packages/gateway/src/utils/ip.ts:18
Ordered list of headers to inspect. Default: [“cf-connecting-ip”, “x-forwarded-for”].
trustedProxies?
Section titled “trustedProxies?”
optionaltrustedProxies?: readonlystring[]
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.
Example
Section titled “Example”// Only trust X-Forwarded-For from Cloudflare IPs{ ipHeaders: ["cf-connecting-ip", "x-forwarded-for"], trustedProxies: ["173.245.48.0/20"] }useRightmostForwardedIp?
Section titled “useRightmostForwardedIp?”
optionaluseRightmostForwardedIp?: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.