Class TrustedProxyOptions

Namespace: redb.Route.Http
Assembly: redb.Route.Http.Hosting.dll

The set of reverse proxies the shared Kestrel host trusts to speak for the client.

public sealed class TrustedProxyOptions

Inheritance

Object→TrustedProxyOptions

Properties

ForwardScheme

Rewrite the request scheme from X-Forwarded-Proto when the peer is trusted. On by

public bool ForwardScheme { get; set; }

IsEnabled

True when at least one proxy or network is listed.

public bool IsEnabled { get; }

KnownNetworks

CIDR networks of trusted reverse proxies.

public List<IPNetwork> KnownNetworks { get; }

KnownProxies

Individual addresses of trusted reverse proxies.

public List<IPAddress> KnownProxies { get; }

Methods

Add(string)

Adds a trusted proxy given as a bare address (10.0.0.5, ::1) or a CIDR

public TrustedProxyOptions Add(string addressOrNetwork)

IsTrusted(IPAddress)

Whether address belongs to a trusted proxy. IPv4-mapped IPv6 addresses

public bool IsTrusted(IPAddress address)

Normalize(IPAddress)

Folds an IPv4-mapped IPv6 address to its IPv4 form; any other address is returned as is.

public static IPAddress Normalize(IPAddress address)

Remarks

A proxy chain is a property of the process, not of a module or a route: two routes on one
port never sit behind different proxies. So the list lives on the host, next to TLS and the
protocol set, and every HTTP-based transport on that host (Http, Soap, As2, Grpc, the Tsak
management API) sees the resolved client address without doing anything itself.


Secure by default: with no entries the host ignores X-Forwarded-For and
X-Forwarded-Proto entirely and the socket peer is the client. Add exactly the addresses
or networks of the proxies you operate. A list that is too wide (a whole cloud range where an
attacker can rent a machine) hands that attacker the right to choose its own client address.