Fix redirect loop when using reverse proxy