class

Lucky::RemoteIpHandler

Inherits Habitat::SettingsHelpers < Habitat::TempConfig < HTTP::Handler < Reference < Object

Sets the HTTP::Request#remote_address value as Socket::IPAddress? to the value of the last IP in the X-Forwarded-For header, or fallback to the default remote_address. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

This will also set a remote_ip String value as String which will be either the raw remote_address value, or an empty string.

This Handler does a "best guess" for the IP which is generally good enough. If you require IP based Authentication, then you may want to handle this on your own as there will be edge cases when related to mobile clients on the go, and potential IP spoofing attacks. More detailed info: https://adam-p.ca/blog/2022/03/x-forwarded-for/

Constants

HABITAT_SETTINGS = [{decl: ip_header_name : String = "X-Forwarded-For", example: nil, validation: nil}] of Nil

Class methods

configure
Source
settings
Source

Instance methods

settings
Source

Nested types