Fix client IP detection behind reverse proxy

The `X-Forwarded-For` header can be easily spoofed by a client. When
forwarding a connection, nginx appends the real detected IP to the the
list. So, what we need is actually the last one on this list, not the
first one.