Bläddra i källkod

Merge pull request #1913 from tarwin/patch-1

Support forwarding through load balancers and proxies
Franco Ponticelli 12 år sedan
förälder
incheckning
43a0c5e022
1 ändrade filer med 5 tillägg och 1 borttagningar
  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;
 	}
 
 	/**