Browse Source

Support forwarding through load balancers and proxies

Tarwin Stroh-Spijer 12 years ago
parent
commit
8e6d55fbb8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      std/php/Web.hx

+ 5 - 1
std/php/Web.hx

@@ -107,7 +107,11 @@ class Web {
 		Surprisingly returns the client IP address.
 	**/
 	public static inline function getClientIP() : String {
-		return untyped __php__("$_SERVER['REMOTE_ADDR']");
+		// support forwarding through load balancers and proxies 
+		var ip = getClientHeader('X_FORWARDED_FOR');
+		if ( ip == null || ip == '' )
+			ip = untyped __php__("$_SERVER['REMOTE_ADDR']");
+		return ip;
 	}
 
 	/**