2
我試圖讓HAProxy的通過傳遞用戶的IP地址我的快遞沒有返回IP地址。這是我在Node.js中使用的代碼:HAProxy的Node.js的+,快遞不轉發IP地址
var usrIP = "0";
if(req.connection.remoteAddress !== null || req.connection.remoteAddress !== "null" || req.connection.remoteAddress.length > 1) {
usrIP = req.connection.remoteAddress;
}
任何想法可能會出錯?
試圖讀取'時,仍然得到同樣的錯誤req.connection.remoteAddress' – user3082584
這解決了它! 'req.headers ['x-forwarded-for']'感謝幫助 – user3082584
'req.headers ['x-forwarded-for']'爲我解決了這個問題,以及在執行 'option httpclose option forwardfor' in haproxy –