This is a collection of WSGI Middleware classes to make applications more usable within a nginx environment
A shim for wsgi applications behind nginx
A common problem that I have ran into when hosting wsgi applications behind a nginx reverse proxy is the rewriting of urls being returned from the upstream server.
This little bit of wsgi middleware will rewrite the script name variable based on a variable set in your nginx config.
Add this line to your nginx config:
proxy_set_header X-SCRIPT-NAME /path;
And this line to your wsgi file:
application = ReverseProxied(application)
Note: Variations of this code exist in other places on the internet. I do not claim to be the person who came up with this. I just love it and need somewhere I can easily find it.
Attempt append a trailing slash to a route without a trailing slash that gets a 404
This can be used when you have primarily routes that end with a slash.
application = TrailingSlash(application)
Force the trailing slash on a route.
This is primarily useful for the root of ones application behind nginx