Changeset - 787f1d157984
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 14 years ago 2012-02-27 18:14:21
marcin@python-works.com
extended https fixup middleware.
1 file changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/middleware/https_fixup.py
Show inline comments
 
@@ -42,13 +42,21 @@ class HttpsFixup(object):
 
        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
0 comments (0 inline, 0 general)