Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes


Detailed Description

This middleware can be applied to add HTTP proxy support to an
application that was not designed with HTTP proxies in mind.  It
sets `REMOTE_ADDR`, `HTTP_HOST` from `X-Forwarded` headers.

Werkzeug wrappers have builtin support for this by setting the
:attr:`~werkzeug.BaseRequest.is_behind_proxy` attribute to `True`.

Do not use this middleware in non-proxy setups for security reasons.

The original values of `REMOTE_ADDR` and `HTTP_HOST` are stored in
the WSGI environment as `werkzeug.proxy_fix.orig_remote_addr` and

:param app: the WSGI application

Definition at line 74 of file

Constructor & Destructor Documentation

Definition at line 91 of file

00092     def __init__(self, app):
00093 = app

Member Function Documentation

def (   self,

Definition at line 94 of file

00095     def __call__(self, environ, start_response):
00096         getter = environ.get
00097         forwarded_for = getter('HTTP_X_FORWARDED_FOR', '').split(',')
00098         forwarded_host = getter('HTTP_X_FORWARDED_HOST', '')
00099         environ.update({
00100             'werkzeug.proxy_fix.orig_remote_addr':  getter('REMOTE_ADDR'),
00101             'werkzeug.proxy_fix.orig_http_host':    getter('HTTP_HOST')
00102         })
00103         if forwarded_for:
00104             environ['REMOTE_ADDR'] = forwarded_for[0].strip()
00105         if forwarded_host:
00106             environ['HTTP_HOST'] = forwarded_host
00107         return, start_response)

Member Data Documentation

Definition at line 92 of file

The documentation for this class was generated from the following file: