Fix URL substitution on reverse proxies

Closes #47.

Thanks to @samary for the report.