From 57d0ec9097201cdd3c88f9a7dfb614a48cb77d5e Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Wed, 7 Feb 2018 08:18:38 -0600 Subject: [PATCH 1/4] Makes app script executable --- icanhaz.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 icanhaz.py diff --git a/icanhaz.py b/icanhaz.py old mode 100644 new mode 100755 From 36bea09b8fc51dd6c98638bc82a98e6e9f93e805 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Wed, 7 Feb 2018 08:26:52 -0600 Subject: [PATCH 2/4] Add requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8ab6294 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask \ No newline at end of file From c0ea0b6c5940133a0cd637bc379cf98b56a7afb6 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Wed, 7 Feb 2018 09:17:52 -0600 Subject: [PATCH 3/4] Add gunicorn to requirements for OpenShift s2i --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8ab6294..f163f4d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -flask \ No newline at end of file +flask +gunicorn \ No newline at end of file From 8b60ea8b435e03af704b448f4f95354af350e856 Mon Sep 17 00:00:00 2001 From: Greg Swift Date: Wed, 7 Feb 2018 09:30:59 -0600 Subject: [PATCH 4/4] Update icanhazip to return IP supporting X-Forwarded-For headers --- icanhaz.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/icanhaz.py b/icanhaz.py index 6bf0934..9efef12 100755 --- 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})