Using Deliverance as Middleware (with Proxying)
December 21st, 2009
Deliverance is a great library that lets you easily re-theme external websites on the fly. Designed as WSGI middleware, it can be easily combined with some proxying to integrate a bunch of websites together
You can use deliverance plus proxying out-of-the-box using the deliverance-proxy command. However, I was interested in using Deliverance as middleware from code. This turned out to be none too trivial to do — all the examples on the internet seemed to focus on using deliverance-proxy or using it in an ini file.
After much wrestling, most notably with odd issues with gzipped (deflated) content I got it working and you can find a demo implementation (see demo.py and README.txt) here:
http://rufuspollock.org/code/deliverance/
I should also mention the following sources which were all of help in my quest:
- http://codespeak.net/svn/z3/deliverance/sandbox/ianb/ploneconf2008/index.txt
- http://www.gawel.org/weblog/en/2008/12/skinning-with-pyquery-and-deliverance
- http://macadames.wordpress.com/2009/05/23/some-deliverance-tips/
- http://www.coactivate.org/projects/deliverance/lists/deliverance-discussion/archive/2009/05/1241444934295/forum_view
- http://www.sixfeetup.com/blog/2009/4/27/deploying-plone-and-zine-together-with-deliverance-using-repoze
Reverse Proxying to Wordpress.com
October 2nd, 2009
I wanted to do a reverse proxy to wordpress.com in order to integrate an existing wordpress.com blog into an existing site. This turned out to be a little trickier than I’d thought due to wordpress.com’s usage of gzip deflation of their output.
Figured this out thanks to sound advice here and here:
...
<Proxy *>
Allow from .mysite.com
</Proxy>
ProxyPass / myblog.wordpress.com
ProxyPassReverse / http://myblog.wordpress.com/
ProxyHTMLURLMap http://myblog.wordpress.com/ /
<Location />
SetOutputFilter proxy-html
# get rid of Content-Encoding at wordpress end
# To use this you'll need to do (on debian) a2enmod headers
RequestHeader unset Accept-Encoding
# Alternative method: inflate then deflate again ... (requires more effort at our end)
# Could NOT get this to work (though suggested by both reference sites!)
# SetOutputFilter INFLATE;proxy-html;DEFLATE
</Location>
....
