X-Forwarded-For can contain multiple IP addresses

From the nginx docs:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html
> $proxy_add_x_forwarded_for
> the “X-Forwarded-For” client request header field with the $remote_addr
> variable appended to it, separated by a comma. If the “X-Forwarded-For”
> field is not present in the client request header, the
> $proxy_add_x_forwarded_for variable is equal to the $remote_addr
> variable.

X-Real-IP is commonly set to $remote_addr, so prefer that if it is
available, otherwise, simply grab the first IP address in
X-Forwarded-For if there are more than one.