Mercurial > kallithea
comparison 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 |
comparison
equal
deleted
inserted
replaced
2053:e121e10d4142 | 2054:787f1d157984 |
---|---|
40 """ | 40 """ |
41 Function to fixup the environ as needed. In order to use this | 41 Function to fixup the environ as needed. In order to use this |
42 middleware you should set this header inside your | 42 middleware you should set this header inside your |
43 proxy ie. nginx, apache etc. | 43 proxy ie. nginx, apache etc. |
44 """ | 44 """ |
45 proto = environ.get('HTTP_X_URL_SCHEME') | |
46 | 45 |
47 if str2bool(self.config.get('force_https')): | 46 if str2bool(self.config.get('force_https')): |
48 proto = 'https' | 47 proto = 'https' |
49 | 48 else: |
49 if 'HTTP_X_URL_SCHEME' in environ: | |
50 proto = environ.get('HTTP_X_URL_SCHEME') | |
51 elif 'HTTP_X_FORWARDED_SCHEME' in environ: | |
52 proto = environ.get('HTTP_X_FORWARDED_SCHEME') | |
53 elif 'HTTP_X_FORWARDED_PROTO' in environ: | |
54 proto = environ.get('HTTP_X_FORWARDED_PROTO') | |
55 else: | |
56 proto = 'http' | |
50 if proto == 'https': | 57 if proto == 'https': |
51 environ['wsgi.url_scheme'] = proto | 58 environ['wsgi.url_scheme'] = proto |
52 else: | 59 else: |
53 environ['wsgi.url_scheme'] = 'http' | 60 environ['wsgi.url_scheme'] = 'http' |
61 | |
54 return None | 62 return None |