Get user's real IP address behind an Amazon AWS load balancer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|<!--- ipaddress if user is behind load balancer --->|
|<cfset my_ip = #GetHttpRequestData().headers['X-Forwarded-For']#>|
|<cfset my_ip = trim(listgetat(my_ip,1))>|
|<!--- ipaddress if user is not behind load balancer --->|
|<cfset my_ip = cgi.remote_addr>|
|Your IP address is: #my_ip#|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can't trust the value of X-Forwarded-For since a user can fake it.