updated ip address detection to use getenv as opposed to _server, and added logic for x_forwarded_for addresses.