Skip to content
Myr

Documented proxy fix

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 0510867 · Browse files · 2 files+36 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+36 added−0 removed

  • other:+36 added−0 removed

2 files+36 added−0 removed

modified:docs/deploying/others.rst+35 added
59 unmodified lines
60.. _Gunicorn: http://gunicorn.org/61.. _eventlet: http://eventlet.net/62.. _greenlet: http://codespeak.net/py/0.9.2/greenlet.html636465Proxy Setups66------------6768If you deploy your application behind an HTTP proxy you will need to69rewrite a few headers in order for the application to work. The two70problematic values in the WSGI environment usually are `REMOTE_ADDR` and71`HTTP_HOST`. Werkzeug ships a fixer that will solve some common setups,72but you might want to write your own WSGI middlware for specific setups.7374The most common setup invokes the host being set from `X-Forwarded-Host`75and the remote address from `X-Forwared-For`::7677 from werkzeug.contrib.fixers import ProxyFix78 app.wsgi_app = ProxyFix(app.wsgi_app)7980Please keep in mind that it is a security issue to use such a middleware81in a non-proxy setup because it will blindly trust the incoming82headers which might be forged by malicious clients.8384If you want to rewrite the headers from another header, you might want to85use a fixer like this::8687 class CustomProxyFix(object):8889 def __init__(self, app):90 self.app = app9192 def __call__(self, environ, start_response):93 host = environ.get('HTTP_X_FHOST', '')94 if host:95 environ['HTTP_HOST'] = host96 return self.app(environ, start_response)9798 app.wsgi_app = CustomProxyFix(app.wsgi_app)
modified:docs/conf.py+1 added
244 unmodified lines
245 'http://docs.python.org/dev': None,246 'http://werkzeug.pocoo.org/documentation/dev/': None,247 'http://www.sqlalchemy.org/docs/': None,248 'http://wtforms.simplecodes.com/docs/0.5/': None,249 # TODO: push to 1.1250 'http://discorporate.us/projects/Blinker/docs/1.0/': None251}252253pygments_style = 'flask_theme_support.FlaskyStyle'
15 unmodified lines