Answer the question
In order to leave comments, you need to log in
How to pass the real ip address of the client through nginx to tomcat?
One server has nginx and tomcat installed. The problem is that nginx passes the address 127.0.0.1 to tomcat (this can be seen in the tomcat logs). An application that runs on tomcat needs real ip addresses of clients. Prior to this, apache was used instead of nginx and real ip addresses of clients were transmitted through it to tomcat.
Fragment of nginx config:
location / {
...
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
...
proxy_pass http://localhost:8080/;
...
}
<Valve className="org.apache.catalina.valves.RemoteIpValve" />
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question