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 Thu, 14 Jun 2012 15:47:27 GMT
Answering my own question to a certain extent:

* When an HTTP/HTTPS request is made, when and how do
> request.getLocalName() and request.getLocalAddr() get filled in?
>From v6.0.35 source code, org/apache/catalina/connector/,
line 489:

        if (connector.getUseIPVHosts()) {
            serverName = req.localName();

When I dig deeper into the source code to where the request's local name is
getting set in the first place, it seems to be getting set from
socket.getLocalAddress(), on
org/apache/catalina/http11/, line 1063.

            if ((localName == null) && (socket != null)) {
                InetAddress inetAddr = socket.getLocalAddress();
                if (inetAddr != null) {
                    localName = inetAddr.getHostName();

So my question is now: why would socket.getLocalAddress() always return the
default interface, rather than resolving the domain/IP in the request
header to the correct interface?
As stated before, in my case, and http:/ are both
directed correctly to my web server, but they are always getting the
following settings:
* request.getLocalAddr():  the IP address from the primary interface in
/etc/network/interfaces =
* request.getLocalName(): the name corresponding to the primary interface
IP from /etc/hosts =
Is there any way to troubleshoot this?


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