Skip to content

Commit 20140c0

Browse files
authored
Merge pull request #30 from mbandizzle/patch-1
Only return one IP address from all three returns
2 parents b596db3 + 1d2504e commit 20140c0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

interceptors/Security.cfc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,16 @@ component accessors="true" extends="coldbox.system.Interceptor" {
729729
private function getRealIP(){
730730
var headers = getHTTPRequestData().headers;
731731

732-
// Very balanced headers
733-
if ( structKeyExists( headers, "x-cluster-client-ip" ) ) {
734-
return headers[ "x-cluster-client-ip" ];
732+
// When going through a proxy, the IP can be a delimtied list, thus we take the last one in the list
733+
734+
if ( structKeyExists( headers, "x-cluster-client-ip" ) ){
735+
return trim( listLast( headers[ "x-cluster-client-ip" ] ) );
735736
}
736-
if ( structKeyExists( headers, "X-Forwarded-For" ) ) {
737-
return headers[ "X-Forwarded-For" ];
737+
if ( structKeyExists( headers, "X-Forwarded-For" ) ){
738+
return trim( listFirst( headers[ "X-Forwarded-For" ] ) );
738739
}
739740

740-
return len( CGI.REMOTE_ADDR ) ? trim( listFirst( CGI.REMOTE_ADDR ) ) : "127.0.0.1";
741+
return len( cgi.remote_addr ) ? trim( listFirst( cgi.remote_addr ) ) : "127.0.0.1";
741742
}
742743

743744
/**

0 commit comments

Comments
 (0)