add support for x-forwarded-for header

add function to use x-forwarded-for or remote-addr if x-forwarded-for is not set to get the remote client ip. this is useful for sites/apps that are behind a load balancer.