class Amber::Pipe::ClientIp

Overview

Saves the real client IP address to context.client_ip.

By default it uses HTTP::Request#client_ip: the peer's own address for an untrusted peer, and for a trusted proxy (server.trusted_proxies) the nearest untrusted hop in the header family the proxy writes (X-Forwarded-For, or Forwarded: for=), read from the right. See Amber::Router::ClientAddress.

Given header names, it reads the first of those headers that is present instead, with the same rule: the header is believed only from a trusted proxy, and walked from the right. Name a header only when the trusted proxy sets it on every request and so overwrites any value a client sent; a proxy passes other headers through unchanged, and the client would choose its own address.

Defined in:

amber/pipes/client_ip.cr

Constructors

Instance Method Summary

Instance methods inherited from class Amber::Pipe::Base

call(context : HTTP::Server::Context) call

Constructor Detail

def self.new(header : String) #

[View source]
def self.new(list_of_header_names : Array(String)) #

[View source]
def self.new #

[View source]

Instance Method Detail

def call(context : HTTP::Server::Context) #
Description copied from class Amber::Pipe::Base

Execution of this handler.


[View source]