framework icon indicating copy to clipboard operation
framework copied to clipboard

get user ip

Open DarkKnight1992 opened this issue 9 years ago • 6 comments

How can i get the user ip ?

I tries with self.headers[x-forwarded-for] but headers is undefined

DarkKnight1992 avatar Oct 27 '17 12:10 DarkKnight1992

Do you use NGINX as reverse proxy? Or do you use something else?

petersirka avatar Oct 27 '17 12:10 petersirka

self.req.ip

dacrhu avatar Oct 27 '17 12:10 dacrhu

we use nginx

@dacrhu will try it.

DarkKnight1992 avatar Oct 27 '17 17:10 DarkKnight1992

Check your Nginx config:

location / {
    proxy_set_header   Host             $http_host;

    proxy_set_header   X-Forwarded-Protocol $scheme;

    # IMPORTANT: SET THE HEADER BELOW
    proxy_set_header   X-Forwarded-For  $remote_addr;

    proxy_set_header   X-NginX-Proxy    true;
    proxy_pass         http://0.0.0.0:8000;
    proxy_redirect     off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade          $http_upgrade;
    proxy_set_header Connection       "upgrade";
    break;
}

petersirka avatar Oct 27 '17 17:10 petersirka

I recommend to use Premium SuperAdmin, it creates similar configs automatically and with SSL certificates.

petersirka avatar Oct 27 '17 18:10 petersirka

thanks for the quick response

DarkKnight1992 avatar Oct 27 '17 18:10 DarkKnight1992