Hack to support https even when the app server http only. The nginx configuration has changed to add the following setting: proxy_set_header X-Scheme $scheme; Using that value to overwrite wsgi.url_scheme in the WSGI environ, which is used by all redirects and other utilities.
(app)
| 721 | |
| 722 | |
| 723 | def https_middleware(app): |
| 724 | """Hack to support https even when the app server http only. |
| 725 | |
| 726 | The nginx configuration has changed to add the following setting: |
| 727 | |
| 728 | proxy_set_header X-Scheme $scheme; |
| 729 | |
| 730 | Using that value to overwrite wsgi.url_scheme in the WSGI environ, |
| 731 | which is used by all redirects and other utilities. |
| 732 | """ |
| 733 | |
| 734 | def wrapper(environ, start_response): |
| 735 | if environ.get("HTTP_X_SCHEME") == "https": |
| 736 | environ["wsgi.url_scheme"] = "https" |
| 737 | return app(environ, start_response) |
| 738 | |
| 739 | return wrapper |
| 740 | |
| 741 | |
| 742 | def runfcgi(func, addr=("localhost", 8000)): |
nothing calls this directly
no outgoing calls
no test coverage detected