silent11 has asked for the wisdom of the Perl Monks concerning the following question:
Yesterday I launched the app under hypnotoad, behind nginx and now I no longer get accurate user IPs. All requests now appear as 127.0.0.1. This would make sense as the requests are coming through nginx.my $ip = $self->tx->remote_address;
with the associated addition to my Nginx config:$self->req->headers->header('X-Real-IP')
However I'm still getting 127.0.0.1 after modifying my app to pull X-Real-IP, and restarting the server :(proxy_set_header X-Real-IP $remote_addr;
upstream myapp { server 127.0.0.1:8080; } server { listen 80; server_name localhost; #include /etc/nginx/proxy_params; location / { proxy_pass http://myapp; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Remote-Port $remote_port; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting visitor IP from Mojolicious::Lite behind Nginx
by beech (Parson) on Oct 18, 2016 at 23:54 UTC |