Add proper handling for reverse proxies

This pull requests adds the option to enable proper handling for reverse proxies, [as done by cherrypy](http://cherrypy.readthedocs.org/en/latest/refman/lib/cptools.html#cherrypy.lib.cptools.proxy).

Currently, it enables handling of the headers:
* `X-Forwarded-Host` - The host received by the proxy
* `X-Forwarded-For` - The IP address connecting to the proxy
* `X-Forwarded-Proto` - The protocol received by the proxy

(This is a copy of #357 based against dev)