108536490: add the proxy_fix

This commit is contained in:
Rebecca Law
2015-11-30 14:32:58 +00:00
parent af382885d3
commit 3f017b30f2
9 changed files with 48 additions and 24 deletions

17
app/proxy_fix.py Normal file
View File

@@ -0,0 +1,17 @@
from werkzeug.contrib.fixers import ProxyFix
class CustomProxyFix(object):
def __init__(self, app, forwarded_proto):
self.app = ProxyFix(app)
self.forwarded_proto = forwarded_proto
def __call__(self, environ, start_response):
environ.update({
"HTTP_X_FORWARDED_PROTO": self.forwarded_proto
})
return self.app(environ, start_response)
def init_app(app):
app.wsgi_app = CustomProxyFix(app.wsgi_app, app.config.get('HTTP_PROTOCOL', 'http'))