浏览代码

Support forwarding through load balancers and proxies

Tarwin Stroh-Spijer 12 年之前
父节点
当前提交
8e6d55fbb8
共有 1 个文件被更改,包括 5 次插入1 次删除
  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;
 	}
 
 	/**