Fixes #6012. Getting correct client IP behind proxy.

I tried it in 1.8, but the code changed very much in 1.9.