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.
'X-Real-IP' request header
'X-Forwarded-For' request header
current request transaction
Returns remote IP address
Viktor Turskyi <email@example.com>
Please report any bugs or feature requests to Github https://github.com/koorchik/Mojolicious-Plugin-RemoteAddr