remote_addr爲具體的某個ip,nginx中配置的是ip-hash算法來負載。初步斷定是由於remote_addr爲固定ip原因造成,經過查前端F5發現做了nat轉換。
對應nginx不是未最前端時,如果前端做了代理,造成remote_addr爲固定ip時可以採用下列方式解決。
1、首先要在代理服務器上開啓_x_forwarded_for,將用戶真實ip插入到http_x_forwarded_for中。
2、在nginx中配置map映射獲取真實ip。map寫在http模塊中
map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
}
3、upstream中的ip-hash改成hash $clientRealIp;