Mercurial > kallithea
diff rhodecode/lib/middleware/https_fixup.py @ 2054:787f1d157984 beta
extended https fixup middleware.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 27 Feb 2012 19:14:21 +0200 |
parents | 89efedac4e6c |
children | 9ab21c5ddb84 8ecfed1d8f8b |
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