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/CoyoteAdapter.java,
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/Http11Processor.java, 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, http://1.2.3.4 and http:/5.6.7.8 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 = http://1.2.3.4
* request.getLocalName(): the name corresponding to the primary interface
IP from /etc/hosts = www.domain1.com
Is there any way to troubleshoot this?

Rgds,
Assaf

Reply via email to