Fix the handling of forward and reverse proxies, as per #1.