I'm using nginx as a load balancer for my web application.
My request flow will be like : User --> Nginx --> Tomcat. I'm trying to get client ip address with "request.getRemoteAddr()" in my java application. However I'm getting nginx server ip as remote address.
I tried real ip solution and header overwrite , none of them seems worked.
My nginx conf
```
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
upstream backend {
server xxxxxx;
}
server {
listen 80;
listen 443;
server_name xxxxxx;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_read_timeout 100;
}
}
```
I can see the correct remote address of client in nginx log. I am able to set the client ip in some other custom header and access it in my java application. But I want the correct client ip in "request.getRemoteAddr()" instead of nginx server ip. Can someone please help?