socketubs/leselys — pull request #93 by mblakele (2013-05-29 00:22:32+00:00)
Title: reverse proxy support

The basic idea is to make sure that leselys will work as a standalone server or behind a reverse proxy, including when configured with a URL prefix like `/leselys/`. This involved wrapping `wsgi_app` in a small custom class to rewrite path info, and modifying quite a bit of javascript and template code to use relative paths instead of rooted paths.

I've done a fair amount of testing, and I think everything still works for standalone servers too. But if you find any problems, just let me know.

Sample nginx config:

# reverse-proxy for leselys
rewrite ^/leselys$ /leselys/ permanent;
location /leselys {
rewrite ^/leselys(/?.*)$ $1 break;
proxy_pass http://127.0.0.1:5000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /leselys;
}