Welcome! Log In Create A New Profile

Advanced

client ip address for ip_hash

Posted by madhu.yadav 
client ip address for ip_hash
June 22, 2022 01:13AM
Hello Team,
We are using nginx ip_hash for load balancing to 2 java/tomcat backends as below
lb -> nginx1,nginx2 -> tomcat1,tomcat2

Right now all requests are going to only one of the tomcats based on its availability and load is not equally distributed.
1. lb is sending the client ip address in X-Forwarded-For header, will this work for ip_hash based load balancing?
2. additionally the format of this header value is "xxx.xxx.xxx.xxx%2" , this '%2' is being added by LB for some internal configuration

Regards,
Madhu



Edited 1 time(s). Last edit at 06/22/2022 01:16AM by madhu.yadav.
Re: client ip address for ip_hash
June 22, 2022 02:05AM
Update on point2 - %2 is now removed and below is a sample log

<LB_IP> - - [22/Jun/2022:11:23:15 +0530] "GET /login HTTP/1.1" 302 154 "https://<url>/""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36" "<http_x_forwarded_for_IP>"--"<http_x_forwarded_for_IP>, <LB_IP>"--

log_format custom '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer"'
'"$http_user_agent" "$http_x_forwarded_for"'
'--"$proxy_add_x_forwarded_for"--';

Does ip_hash work based on http_x_forwarded_for header value?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 125
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready