Improved get_ip function to work better with multiple x-forwarded-for ips