Skip to content

Instantly share code, notes, and snippets.

@MWers
Created April 4, 2014 04:16
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