Retrieving the originating IP address of the request is simple in most languages.
Here’s how to retrieve the IP address in Java ( req represents a javax.servlet.http.HttpServletRequestreference ):
String ip = req.getRemoteAddr();
Here’s the same line in Go ( r represents http.Request ):
ip := r.RemoteAddr
In PHP, the originating IP can be retrieved from the predefined variable SERVER :
$_SERVER['REMOTE_ADDR']