2012-09-18 56 views
1

我的網絡服務器(主機nginx的Facebook應用)開始接收錯誤說Nginx的IPv6的配置文檔

*907768 FastCGI sent in stderr: "Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server" while reading response header from upstream, client:... 

可能是什麼這個錯誤的原因是什麼?我並不總是這樣。

回答

2

錯誤來自於php代碼,更具體地說 - facebook sdk。當Facebook的代碼會嘗試連接到IPv6地址,並不能達到網絡它拋出,很可能是由於IPv6的系統啓用,但沒有IPv6連接(引自base_facebook.php):

// With dual stacked DNS responses, it's possible for a server to 
// have IPv6 enabled but not have IPv6 connectivity. If this is 
// the case, curl will try IPv4 first and if that fails, then it will 
// fall back to IPv6 and the error EHOSTUNREACH is returned by the 
// operating system. 
if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) { 
    $matches = array(); 
    $regex = '/Failed to connect to ([^:].*): Network is unreachable/'; 
    if (preg_match($regex, curl_error($ch), $matches)) { 
     if (strlen(@inet_pton($matches[1])) === 16) { 
     self::errorLog('Invalid IPv6 configuration on server, '. 
         'Please disable or get native IPv6 on your server.'); 
     self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; 
     curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 
     $result = curl_exec($ch); 
     } 
    } 
} 

正確的方式來處理這個問題將要麼禁用系統中的ipv6,要麼獲得一些ipv6連接。另外,它應該可以通過詢問Facebook的代碼總是被什麼東西在你的代碼中使用的IPv4這樣來取消錯誤:

Facebook::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; 
+0

感謝您的回答,你能告訴我,我可以把那個片段中基的Facebook .PHP? – berkayk

+0

該代碼片段用於_your_代碼,放在'require'/ path/to/facebook.php'後面。我不會推薦編輯base_facebook.php。這樣你就可以安全地從Facebook更新base_facebook.php。如果您可以編輯Facebook sdk,請將該選項直接放入[$ CURL_OPTS](https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L133)數組中。 –

+0

非常感謝。乾杯。 – berkayk