Fix URL substitution on reverse proxies

Closes #47.