changeset 2054:787f1d157984 beta

extended https fixup middleware.
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 27 Feb 2012 19:14:21 +0200
parents e121e10d4142
children c8a8684efc74
files rhodecode/lib/middleware/https_fixup.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/middleware/https_fixup.py	Mon Feb 27 18:58:47 2012 +0200
+++ b/rhodecode/lib/middleware/https_fixup.py	Mon Feb 27 19:14:21 2012 +0200
@@ -42,13 +42,21 @@
         middleware you should set this header inside your
         proxy ie. nginx, apache etc.
         """
-        proto = environ.get('HTTP_X_URL_SCHEME')
 
         if str2bool(self.config.get('force_https')):
             proto = 'https'
-
+        else:
+            if 'HTTP_X_URL_SCHEME' in environ:
+                proto = environ.get('HTTP_X_URL_SCHEME')
+            elif 'HTTP_X_FORWARDED_SCHEME' in environ:
+                proto = environ.get('HTTP_X_FORWARDED_SCHEME')
+            elif 'HTTP_X_FORWARDED_PROTO' in environ:
+                proto = environ.get('HTTP_X_FORWARDED_PROTO')
+            else:
+                proto = 'http'
         if proto == 'https':
             environ['wsgi.url_scheme'] = proto
         else:
             environ['wsgi.url_scheme'] = 'http'
+
         return None