internetdata_selectors (internetdata v1.17.1)
View SourceHow the client address is decided.
There is no portable default: a framework's own accessor may return the socket peer, or may already have walked a proxy chain, depending on the framework and on how the application configured it. You know your framework and your edge, so this is yours to choose - and anything of this shape works, so an edge we have never heard of is a fun rather than a feature request:
fun(View) -> (maps:get(header, View))(<<"x-real-ip">>) end
Summary
Functions
The framework's own client-address accessor. The default.
An address from a single-value header your edge writes - header(<<"cf-connecting-ip">>) behind Cloudflare. Falls back to the framework's accessor when the header is absent.
The source address of a PROXY protocol header (v1 or v2), read only on a connection from Trusted, a list of addresses or CIDR blocks your balancers send from. For a listener started with proxy_header => true behind a balancer that speaks the protocol, such as nginx's stream module with proxy_protocol on or HAProxy's send-proxy.
Run a selector over one request view.
An address from X-Forwarded-For.
Types
Functions
-spec framework_ip() -> selector().
The framework's own client-address accessor. The default.
An address from a single-value header your edge writes - header(<<"cf-connecting-ip">>) behind Cloudflare. Falls back to the framework's accessor when the header is absent.
The source address of a PROXY protocol header (v1 or v2), read only on a connection from Trusted, a list of addresses or CIDR blocks your balancers send from. For a listener started with proxy_header => true behind a balancer that speaks the protocol, such as nginx's stream module with proxy_protocol on or HAProxy's send-proxy.
The header is whatever the connecting peer wrote, so on a connection from anywhere else, or one whose header names no source (a balancer's own health check), this answers the socket peer. Raises {badarg, {trusted, Spec}} for an entry that is not an address or a CIDR block.
Run a selector over one request view.
-spec xff(non_neg_integer()) -> selector().
An address from X-Forwarded-For.
The LEFT-MOST entry (Depth 0) is whatever the caller sent, because proxies append to this header, so a visitor who sets it themselves appears first and this returns their forgery. It is only trustworthy when an edge you control overwrites the header. When you know how many proxies sit in front, count from the right: depth 1 is the address your nearest proxy saw.