Answer the question
In order to leave comments, you need to log in
How to determine where the request came from lan or because of nat?
Good afternoon!
You need to make sure that the application behavior is separated for users who logged in through the local network and users who logged in through nat.
python 3, Django 1.8, apache 2.4.
virtual host configuration:
<VirtualHost *:8080>
WSGIScriptAlias / /www/pi/pi/wsgi.py
#WSGIPythonPath /www/pi/
<Directory /www/pi>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR')
return ip
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question