Mojolicious::Plugin::RemoteAddr - an easy way of getting remote ip address
# Mojolicious $self->plugin('RemoteAddr'); # In controller my $ip = $self->remote_addr;
Mojolicious::Plugin::RemoteAddr adds simple helper "remote_addr" which returns an ip address of a remote host, It tries getting remote ip in different ways. Firstly, it takes 'X-Real-IP' header. Secondly, it takes 'X-Forwarded-For' header. If they are empty it takes the ip from current request transaction.
Lookup order. Default is ['x-real-ip', 'x-forwarded-for', 'tx']
If you do not have reverse proxy then set order to ['tx'] to avoid ip-address spoofing.
Supported places:
'X-Real-IP' request header
'X-Forwarded-For' request header
current request transaction
Returns remote IP address
Viktor Turskyi <koorchik@cpan.org>
Please report any bugs or feature requests to Github https://github.com/koorchik/Mojolicious-Plugin-RemoteAddr
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
To install Mojolicious::Plugin::RemoteAddr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::RemoteAddr
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::RemoteAddr
For more information on module installation, please visit the detailed CPAN module installation guide.