chenjunkai 6 years ago
parent
commit
cd850091fb
1 changed files with 5 additions and 0 deletions
  1. 5 0
      Service/CommonService.py

+ 5 - 0
Service/CommonService.py

@@ -65,6 +65,11 @@ class CommonService:
         :param request:
         :return:
         """
+        ip = request.META.get("X-Forwarded-For","")
+        if ip:
+            client_ip = ip.split(",")[0].strip() if ip else ""
+            if client_ip:
+                return client_ip
         ip = request.META.get("HTTP_X_FORWARDED_FOR", "")
         if not ip:
             ip = request.META.get('REMOTE_ADDR', "")