Gustavo Rozolin Gustavo Rozolin - 5 months ago 87
Apache Configuration Question

apache and tomcat get remote ip

I have this setting in my apache, this work fine, but in my app when a get remote address this return local IP (, how I solve this problem?

</VirtualHost><VirtualHost *:80>
ServerAlias yourapp.*
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
ProxyPass /webapp http://localhost:8080/webapp
ProxyPassReverse /webapp http://localhost:8080/webapp
<Location /webapp>
Order allow,deny
Allow from all

Answer Source

You can use Remote_IP_Valve to set the actual IP address in the request.

In your tomcat/conf/server.xml add the valve like

<Valve className="org.apache.catalina.valves.RemoteIpValve"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download