The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::RemoteAddr - an easy way of getting remote ip address

SYNOPSIS

  # Mojolicious
  $self->plugin('RemoteAddr');

  # In controller
  my $ip = $self->remote_addr;

DESCRIPTION

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.

CONFIG

order

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'

'X-Real-IP' request header

'x-forwarded-for'

'X-Forwarded-For' request header

'tx'

current request transaction

HELPERS

remote_addr

Returns remote IP address

AUTHOR

Viktor Turskyi <koorchik@cpan.org>

BUGS

Please report any bugs or feature requests to Github https://github.com/koorchik/Mojolicious-Plugin-RemoteAddr

SEE ALSO

Mojolicious, Mojolicious::Guides, http://mojolicio.us.