Skip to content

Instantly share code, notes, and snippets.

@clayg
Created September 23, 2016 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/0864f5a18be7995acc85cd03814dcedd to your computer and use it in GitHub Desktop.
Save clayg/0864f5a18be7995acc85cd03814dcedd to your computer and use it in GitHub Desktop.
diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py
index 6b62fb2..b9e96fa 100644
--- a/swift/common/wsgi.py
+++ b/swift/common/wsgi.py
@@ -415,6 +415,12 @@ class SwiftHttpProtocol(wsgi.HttpProtocol):
class SwiftHttpProxiedProtocol(SwiftHttpProtocol):
+
+ def get_environ(self):
+ env = SwiftHttpProtocol.get_environ(self)
+ env.update(getattr(self, 'update_environ', {}))
+ return env
+
def parse_request(self):
"""
Require HAProxy PROXY protocol, version 1.
@@ -432,6 +438,11 @@ class SwiftHttpProxiedProtocol(SwiftHttpProtocol):
if known or proxy_parts[1].startswith('UNKNOWN'):
self.raw_requestline = self.rfile.readline(
self.server.url_length_limit)
+ if proxy_parts[5] == '443':
+ self.update_environ = {
+ 'wsgi.url_scheme': 'https',
+ 'HTTPS': 'on',
+ }
return wsgi.HttpProtocol.parse_request(self)
self.send_error(400, 'Bad PROXY line: %r' %
self.raw_requestline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment