Skip to content
Snippets Groups Projects
Commit c30037de authored by Vermaat's avatar Vermaat
Browse files

Add REVERSE_PROXIED configuration setting

parent 511f03c8
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,12 @@ MAX_CACHE_SIZE = 50 * 1048576 # 50 MB
# Maximum size for uploaded and downloaded files (in bytes).
MAX_FILE_SIZE = 10 * 1048576 # 10 MB
# The WSGI application runs behind a reverse proxy (e.g., nginx using
# proxy_pass). This needs to be set if the application is mapped to a URL
# other than / or a different HTTP scheme is used by the reverse proxy.
# http://flask.pocoo.org/snippets/35/
REVERSE_PROXIED = False
# Redis connection URI (can be any redis-py connection URI). Set to `None` to
# silently use a mock Redis. Redis is only used for non-essential features.
REDIS_URI = None
......
......@@ -14,7 +14,7 @@ from mutalyzer.db import session
# Todo: Perhaps we also need this for the RPC services?
class ReverseProxied(object):
class _ReverseProxied(object):
"""
Wrap the application in this middleware and configure the front-end server
to add these headers, to let you quietly bind this to a URL other than /
......@@ -62,6 +62,9 @@ def create_app():
template_folder=os.path.abspath(template_folder),
static_folder=os.path.abspath(static_folder))
if settings.REVERSE_PROXIED:
app.wsgi_app = _ReverseProxied(app.wsgi_app)
app.config.update(DEBUG=settings.DEBUG,
TESTING=settings.TESTING,
MAX_CONTENT_LENGTH=settings.MAX_FILE_SIZE)
......@@ -80,14 +83,3 @@ def create_app():
session.remove()
return app
def create_reverse_proxied_app():
"""
Create a Flask instance for Mutalyzer running behind a reverse proxy.
See :func:`create_app` and :class:`ReverseProxied`.
"""
app = create_app()
app.wsgi_app = ReverseProxied(app.wsgi_app)
return app
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment