If you have set up the reverse proxy correct, you can just do $c->remote_address;
No idea why you want to look into the tx hash. You should always use the methods. Look here: (there's also cookbooks for other servers on that page) https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Nginx https://metacpan.org/pod/Mojo::Transaction#remote_address Also remember to set the MOJO_REVERSE_PROXY=1 environmnt variable as I said earlier in this thread. https://metacpan.org/pod/Mojo::Server#reverse_proxy https://metacpan.org/pod/Mojo::Server::Hypnotoad#proxy On Wednesday, July 23, 2014 1:17:54 PM UTC+2, Юрий Корик wrote: > > What's the right way to retrieve the client's IP address? > > Create helper: > > $self->renderer->add_helper(ip => sub { > my $self = shift; > my $for = $self->req->headers->header('X-Forwarded-For'); > return $for && $for !~ /unknown/i ? $for : undef || > $self->req->headers->header('X-Real-IP') || $self->tx->{remote_address}; > }); > >> >> -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
