Skip to content

Instantly share code, notes, and snippets.

@MWers
Created April 4, 2014 04:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MWers/9968031 to your computer and use it in GitHub Desktop.
Save MWers/9968031 to your computer and use it in GitHub Desktop.
Use X-Forwarded-For address if it exists, otherwise use cgi.remote_addr
<cfset req = GetHttpRequestData() />
<cfif structKeyExists(req.headers, "X-Forwarded-For")
AND Len(Trim(req.headers["X-Forwarded-For"])) GT 0>
<cfset ipAddress = req.headers["X-Forwarded-For"] />
<cfelse>
<cfset ipAddress = cgi.remote_addr />
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment