Hello Ivan, The headers x-forwarded-for, x-forwarded-host and x-forwarded-server are typically added by Apache Httpd mod_proxy (1).
It seems that you use Apache Httpd mod_proxy in front of your Tomcat, both located on the same server (this is the reason why get localhost). Your solution may be to look at the "ProxyPreserveHost On" directive in Apache configuration (2). If you use It would look like : ProxyPreserveHost On ProxyPass /mypath http://localhost:8080/mypath Hope this helps, Cyrille -- Cyrille Le Clerc clecl...@xebia.fr http://blog.xebia.fr (1) see http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers (2) see http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost On Wed, Mar 3, 2010 at 5:09 PM, vgud <ivan.gudi...@yahoo.com> wrote: > > I tried to log all request headers and notice three interesting headers: > > x-forwarded-for : 10.0.0.24 > x-forwarded-host : myRealDomain.com > x-forwarded-server : my.server.ip.address > > So, tomcat(or someone else) does some forwarding and attach those headers on > request? > > If so where and how it is configured? > > > n828cl wrote: > > > >> From: André Warnier [mailto:a...@ice-sa.com] > >> Subject: Re: getServerName returns 'localhost' > >> > >> public java.lang.String getServerName() > >> Returns the host name of the server to which the request was sent. > >> It is the value of the part before ":" in the Host header value, if > >> any, or the resolved server name, or the server IP address. > >> Returns: > >> a String containing the name of the server > >> > >> That does not seem to work in his case. > >> > >> Does it only work when the <Host> or <Alias> tags with the > >> corresponding names are set ? > > > > The code shows that the HOST header is being used by getServerName(). > > Testing with the RequestDumperFilter enabled in examples/WEB-INF/web.xml > > shows that it works as documented; here's a portion of the output from > > Tomcat running on my desktop with the default <Host> name of localhost: > > serverName=usrv-caldarcr.na.uis.unisys.com > > serverPort=8080 > > > > It appears the OP has something else going on that's interfering with the > > target IP address. (Internal routing, perhaps?) > > > > - Chuck > > > > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY > > MATERIAL and is thus for use only by the intended recipient. If you > > received this in error, please contact the sender and delete the e-mail > > and its attachments from all computers. > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: users-h...@tomcat.apache.org > > > > > > > > -- > View this message in context: > http://old.nabble.com/getServerName-returns-%27localhost%27-tp27767838p27770177.html > Sent from the Tomcat - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org