Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.contrib.fixers.ProxyFix Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 app

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
`werkzeug.proxy_fix.orig_http_host`.

:param app: the WSGI application

Definition at line 74 of file fixers.py.


Constructor & Destructor Documentation

Definition at line 91 of file fixers.py.

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


Member Function Documentation

def MoinMoin.support.werkzeug.contrib.fixers.ProxyFix.__call__ (   self,
  environ,
  start_response 
)

Definition at line 94 of file fixers.py.

00094 
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 self.app(environ, start_response)
00108 


Member Data Documentation

Definition at line 92 of file fixers.py.


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