Plack::Middleware::RealIP - Override client IP with header value provided by proxy/load balancer
enable 'Plack::Middleware::RealIP', header => 'X-Forwarded-For', trusted_proxy => [qw(192.168.1.0/24 192.168.2.1)];
Plack::Middleware::RealIP is loose port of the Apache module mod_remoteip. It overrides
REMOTE_ADDR with the IP address advertised in the request header configured with
When multiple, comma delimited IP addresses are listed in the header value, they are processed from right to left. The first untrusted IP address found, based on
trusted_proxy, stops the processing and is set to be
REMOTE_ADDR. The header field is updated to this remaining list of unconfirmed IP addresses, or if all IP addresses were trusted, this header is removed from the request altogether.
Sets a request header to trust as the client IP, e.g. X-Client-IP
A list of IP addresses or subnet blocks which are trusted to provide IP header.
Sherwin Daganato <email@example.com>
Most of the logic is based on Plack::Middleware::XForwardedFor by Graham Barr
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.