python - Django runserver bound to 0.0.0.0, how can I get which IP took the request? -


i'm running temporary django app on host has lots of ip addresses. when using manage.py runserver 0.0.0.0:5000, how can code see of many ip addresses of machine 1 hit request, if possible?

or put way:

my host has ip addresses 10.0.0.1 , 10.0.0.2. when runserver listening on 0.0.0.0, how can application know whether user hit http://10.0.0.1/app/path/etc or http://10.0.0.2/app/path/etc?

i understand if doing apache use apache environment variables server_addr, i'm not using apache.

any thoughts?

edit

more information:

i'm testing load balancer using small django app. app listening on number of different ips , need know ip address hit request coming through load balancer, can ensure balancing properly.

i cannot use request.get_host() or request.meta options, return user typed hit load balancer.

for example: user hits http://10.10.10.10/foo , forward request either http://10.0.0.1/foo or http://10.0.0.2/foo - request.get_host() return 10.10.10.10, not actual ips server listening on.

thanks, ben

request.get_host() 

https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.httprequest.get_host

but aware can cheated don't relay security on it.

if users seeing machine under same address not sure if possible via runserver (it supposed simple development tool).

maybe use nginx? or if testing like:

for in 1 2 3 4 5; manage.py runserver 10.0.0.$i:5000; done 

and sys.args[2] address


Comments