Cecil
19+ years progress programming and still learning.
Here is a little function I've written for returning the IP Address of the client vs proxy's IP address. Feel fee to use it. Hope it helps you.
I want to record the IP Address of all users connecting to my web application. The problem was the IP address was always returning the internal proxy server IP Address and not the client. This was my solution.
I want to record the IP Address of all users connecting to my web application. The problem was the IP address was always returning the internal proxy server IP Address and not the client. This was my solution.
Code:
FUNCTION GetRealIPAddress RETURNS CHARACTER():
DEFINE VARIABLE chIPAddress AS CHARACTER NO-UNDO.
CASE TRUE:
WHEN get-cgi('HTTP_CLIENT_IP':U) NE '' THEN
chIPAddress = get-cgi('HTTP_CLIENT_IP':U).
WHEN get-cgi('HTTP_X_FORWARDED_FOR':U) NE '' THEN
chIPAddress = get-cgi('HTTP_X_FORWARDED_FOR':U).
WHEN get-cgi('HTTP_X_FORWARDED':U) NE '' THEN
chIPAddress = get-cgi('HTTP_X_FORWARDED':U).
WHEN get-cgi('HTTP_FORWARDED_FOR':U) NE '' THEN
chIPAddress = get-cgi('HTTP_FORWARDED_FOR':U).
WHEN get-cgi('HTTP_FORWARDED':U) NE '' THEN
chIPAddress = get-cgi('HTTP_FORWARDED':U).
OTHERWISE
chIPAddress = get-cgi('REMOTE_ADDR':U).
END CASE.
RETURN chIPAddress.
END FUNCTION.
{&OUT} GetRealIPAddress().