0

I have Python Flask API hosted on server through a prodID.Meanwhile i want to know my client/visitor -> IP/username to keep track of my website visit count. But unfortunately i don't receive the same,rather i get my server IP for the different instances.

1)Have used:

request.remote_addr;

or

request.environ['REMOTE_ADDR'];

3)Similarly i tried getting hostname:

import getpass;
getpass.getuser()

import socket;
socket.gethostname()

Here too i get the Prodid username with which the server was hosted.Rather my username when API is called.

Any help would be highly appreciated.

Janardhan
  • 1
  • 2
  • Here are some more options to try: https://stackoverflow.com/questions/3759981/get-ip-address-of-visitors – wholevinski Feb 26 '18 at 14:04
  • Here basically i require the IPv4 address IP,or unique IP of my client to keep track on count. – Janardhan Feb 26 '18 at 14:04
  • had gone through the URL shared,its the same thing which i have tried of.Any other way to solve out?? – Janardhan Feb 26 '18 at 14:26
  • This is due to a reverse proxy hosting setup (e.g. nginx?) try `request.environ['X-Forwarded-For']` or please provide more information about your setup. There are configurations you can use to tell nginx to put the correct IP so that `request.remote_addr` will work as expected – abigperson Feb 26 '18 at 17:39
  • Any input on the query?? – Janardhan Feb 26 '18 at 17:53
  • The setup done is simple flask API call,which sends me back the server IP perhaps,and not the client IP,as i saw on logs 2 users were having the same IP.I am using webfarm as server setup where my .cgi file triggers the flask API to run.What settings can i do to achieve the user IP – Janardhan Feb 26 '18 at 18:32
  • The other alternative which i have tried is: https://stackoverflow.com/questions/48991829/how-to-get-client-user-ip-address-visiting-my-webpage-in-javascript-jquery – Janardhan Feb 26 '18 at 18:41
  • Any input on solving the problem? – Janardhan Feb 27 '18 at 05:43
  • Finally with` request.access_route[0] i get the IPv4 address of User/Client visiting the page. – Janardhan Feb 27 '18 at 09:37

0 Answers0