0

Im trying to get client ip, im using flask and nginx.

what i tried so far:

request.environ['REMOTE_ADDR']

request.environ['HTTP_X_FORWARDED_FOR']

request.remote_addr

socket.gethostbyname(socket.gethostname())

request.headers.get('X-Forwarded-For', request.remote_addr)

I keep getting address that start with 172... ip (which is not mine).

My conf file:

proxy_pass http://app_servers;

proxy_set_header  Host $host;

proxy_set_header  X-Real-IP $remote_addr;

proxy_set_header  X-Forwarded-Proto https;

proxy_set_header  X-Forwarded-For $remote_addr;

proxy_set_header  X-Forwarded-Host $remote_addr;

Any idea what can i do? also - do you know maybe which IP im really getting for the commands i tried?

WSM_Syeli
  • 9
  • 1
  • Does this answer your question? [get Client IP in a flask based application](https://stackoverflow.com/questions/49049088/get-client-ip-in-a-flask-based-application) – pjcunningham Feb 27 '23 at 22:20

0 Answers0