I need to obtain the IP of the request that reaches the Resource for business validation purposes. Please help if someone has done it.
I have tried:
String ipAddress = request.getRemoteAddr();
String ipAddress1 = request.getHeader("X-Forwarded-For");
But in the first case, it returns the address 0:0:0:0:0:0:0:1, and in the second case it returns null.
Looks like your application is behind a proxy,
Couple of things you need to do.
location / {
proxy_pass http://localhost:8080;
proxy_read_timeout 7200s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 200M;
}
server.forward-headers-strategy= native