mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 10:54:18 +00:00
Use werkzeugs pre implemented ProxyFix middleware
This commit is contained in:
parent
814821a2bd
commit
94d99862bd
@ -7,17 +7,6 @@ from flask_sqlalchemy import SQLAlchemy
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class CustomProxyFix(object):
|
|
||||||
def __init__(self, app):
|
|
||||||
self.app = app
|
|
||||||
|
|
||||||
def __call__(self, environ, start_response):
|
|
||||||
scheme = environ.get('HTTP_X_FORWARDED_PROTO')
|
|
||||||
if scheme:
|
|
||||||
environ['wsgi.url_scheme'] = scheme
|
|
||||||
return self.app(environ, start_response)
|
|
||||||
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
@ -28,7 +17,6 @@ socketio = SocketIO()
|
|||||||
|
|
||||||
def create_app(config_name):
|
def create_app(config_name):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.wsgi_app = CustomProxyFix(app.wsgi_app)
|
|
||||||
app.config.from_object(config[config_name])
|
app.config.from_object(config[config_name])
|
||||||
|
|
||||||
config[config_name].init_app(app)
|
config[config_name].init_app(app)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -33,7 +34,13 @@ class Config:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def init_app(app):
|
def init_app(app):
|
||||||
pass
|
proxy_fix_kwargs = {
|
||||||
|
'x_for': 1,
|
||||||
|
'x_host': 1,
|
||||||
|
'x_port': 1,
|
||||||
|
'x_proto': 1,
|
||||||
|
}
|
||||||
|
app.wsgi_app = ProxyFix(app.wsgi_app, **proxy_fix_kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DevelopmentConfig(Config):
|
class DevelopmentConfig(Config):
|
||||||
|
Loading…
Reference in New Issue
Block a user