In my case, I was using Nginx in front of my application with the following configuration:
location / {
proxy_pass http://localhost:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
add_header Content-Security-Policy 'upgrade-insecure-requests';
}
so in my application I get the real user ip like so:
String clientIP = request.getHeader("X-Real-IP");