Werkzeug

Fixers

New in version 0.5.

This module include various helpers that fix bugs in web servers. They may be necessary for some versions of a buggy web server but not others. We try to stay updated with the status of the bugs as good as possible but you have to make sure if they fix the problem you encounter.

If you notice bugs in webservers not fixed in this module consider contributing a patch.

class werkzeug.contrib.fixers.LighttpdCGIRootFix(app)
Wrap the application in this middleware if you are using lighttpd with FastCGI or CGI and the application is mounted in the URL root.
class werkzeug.contrib.fixers.PathInfoFromRequestUriFix(app)

On windows environment variables are limited to the system charset which makes it impossible to store the PATH_INFO variable in the environment without loss of information on some systems.

This is for example a problem for a CGI scripts on a Windows Apache.

This fixer works by recreating the PATH_INFO from REQUEST_URI, REQUEST_URL, or UNENCODED_URL (whatever is available). Thus the fix can only be applied if the webserver supports either of these variables.

class werkzeug.contrib.fixers.ProxyFix(app)

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 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.