tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Assaf Urieli <>
Subject Re: IP-based virtual hosting with useIPVHosts=true always goes to default host
Date Fri, 08 Jun 2012 15:12:13 GMT

> Looking at the code, the value used for host name in IP-based virtual
> hosts is ServletRequest.getLocalName(). It is not getLocalAddr() and
> there is no pattern in AccessLogValve that prints it. You can write
> simple JSP page that will display its value.

Ok, this is strange. I created a test.jsp page that prints
request.getLocalName(), request.getServerName(), and request.getLocalAddr().
I tried various scenarios in the browser:,, http:/,,,, as well as all of the above with
The only parameter that changes in all these scenarios is
request.getLocalName() = (always!)
request.getLocalAddr() = (always!)
request.getServerName() =,,,,,

> Quote:
> [[[
>        if (connector.getUseIPVHosts()) {
>            serverName = req.localName();
> ]]]
> Which explains why useIPVHosts changes nothing for me -
request.getLocalName() is always giving the same result.
What is it that sets request.getLocalName() in the first place? In what
scenario would the name be different?

> >
> > Even if I enter the IP address or in the
> > browser, the access logs list as the local IP.
> >
> This is odd.
> How is configured at OS level? Do you have separate network
> card for it or it is something else?

My /etc/network/interfaces file looks like this:
# The loopback interface
auto lo
iface lo inet loopback

# Configuration for eth0 and aliases

# This line ensures that the interface will be brought up during boot.
auto eth0 eth0:0
#iface eth0 inet dhcp

# eth0 - This is the main IP address that will be used for most outbound
# The address, netmask and gateway are all necessary
iface eth0 inet static
        pre-up iptables-restore < /etc/iptables.conf

# eth0:0
# This is a second public IP address.
iface eth0:0 inet static
        pre-up iptables-restore < /etc/iptables.conf

> Your connector with address="" - did it start successfully and
> did bind to the specified address? Tomcat itself will continue
> starting even if one of its connectors fails. (There is a system
> property that changes this behaviour of ignoring an error, though I do
> not remember whether it works in 6.0.24).

How does one find out if a connector starts successfully and binds at a
specific address? Is there a log somewhere for this information? Nothing
obvious was written to the catalina.yyyy-MM-dd.log indicating failure.

> Best regards,
> Konstantin Kolinko
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
Best regards,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message