framework
framework copied to clipboard
get user ip
How can i get the user ip ?
I tries with self.headers[x-forwarded-for] but headers is undefined
Do you use NGINX as reverse proxy? Or do you use something else?
self.req.ip
we use nginx
@dacrhu will try it.
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;
}
I recommend to use Premium SuperAdmin, it creates similar configs automatically and with SSL certificates.
thanks for the quick response