diff --git a/icanhaz.py b/icanhaz.py old mode 100644 new mode 100755 index 6bf0934..9efef12 --- a/icanhaz.py +++ b/icanhaz.py @@ -90,7 +90,9 @@ def icanhazafunction(): result = json.dumps(dict(request.headers)) else: # The request is for *.icanhazip.com or something we don't recognize - result = request.remote_addr + # This method should pull the correct hop even with load balancers in the way + # https://stackoverflow.com/questions/33818540/how-to-get-the-first-client-ip-from-x-forwarded-for-behind-nginx-gunicorn + result = request.access_route[0] return Response("%s\n" % result, mimetype="text/plain", headers={'X-Your-Ip': request.remote_addr}) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f163f4d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +flask +gunicorn \ No newline at end of file