소스 검색

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;
 	}
 
 	/**