Skip to content

Commit b9cd3fd

Browse files
committed
really get source ip due to nginx+gunicorn
1 parent 35590cd commit b9cd3fd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

back/app_flask.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ def register():
357357

358358
if settings.country_check != '':
359359
# anti bots
360-
r = requests.get(f"http://ip-api.com/json/{request.remote_addr}")
360+
ip = request.environ.get('HTTP_X_FORWARDED_FOR', request.remote_addr)
361+
r = requests.get(f"http://ip-api.com/json/{ip}")
361362
if r.status_code == 200 and r.json()['country'] != settings.country_check:
362363
return "Blocked", 403
363364

0 commit comments

Comments
 (0)