Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Werkzeug ProxyFix middleware #1150

Merged
merged 1 commit into from
Sep 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions caravel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from flask_appbuilder.baseviews import expose
from flask_cache import Cache
from flask_migrate import Migrate
from werkzeug.contrib.fixers import ProxyFix


APP_DIR = os.path.dirname(__file__)
Expand Down Expand Up @@ -77,6 +78,9 @@ def checkout(dbapi_con, con_record, con_proxy):
from flask_cors import CORS
CORS(app, **app.config.get('CORS_OPTIONS'))

if app.config.get('ENABLE_PROXY_FIX'):
app.wsgi_app = ProxyFix(app.wsgi_app)


class MyIndexView(IndexView):
@expose('/')
Expand Down
3 changes: 3 additions & 0 deletions caravel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
# Whether to show the stacktrace on 500 error
SHOW_STACKTRACE = True

# Extract and use X-Forwarded-For/X-Forwarded-Proto headers?
ENABLE_PROXY_FIX = False

# ------------------------------
# GLOBALS FOR APP Builder
# ------------------------------
Expand Down
4 changes: 4 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ load balancer knows if your caravel instance is running. This is provided
at ``/health`` which will return a 200 response containing "OK" if the
webserver is running.

If the load balancer is inserting X-Forwarded-For/X-Forwarded-Proto headers, you
should set `ENABLE_PROXY_FIX = True` in the caravel config file to extract and use
the headers.


Configuration
-------------
Expand Down