https://bz.apache.org/bugzilla/show_bug.cgi?id=59868
Christopher Schultz <ch...@christopherschultz.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #4 from Christopher Schultz <ch...@christopherschultz.net> ---
(In reply to Michael Osipov from comment #0)
> I have configured my Connector to listen to address="127.0.0.1" only. Single
> hostname for this is "localhost". Though, the HTMLManager displays in Server
> Information my regular host name and the IP address of the second NIC
> (VirtualBox Host-Only Adapter).
>
> Code:
>         try {
>             InetAddress address = InetAddress.getLocalHost();
>             args[6] = address.getHostName();
>             args[7] = address.getHostAddress();
>         } catch (UnknownHostException e) {
>             args[6] = "-";
>             args[7] = "-";
>         }
> 
> I would expect to display the information this Connector and Host is
> accepting, remove this information altogether or document that this
> information does not reflect configuration
> (docs/html-manager-howto.html#Server_Information).

Yeah, InetAddress.getLocaleHost() doesn't behave the way that most people would
expect. Most people would expect it to grab the "localhost" IP address and use
that. It doesn't.

Instead, it asks the OS what the hostname of the current machine is, then uses
that. So if your hostname is "erasmus", then InetAddress.getLocalHost will
return that name + its IP address even if you have bound the connector to
127.0.0.1.

Note that there is no relationship whatsoever between your <Connector> and
InetAddress.getLocaLhost. InetAddress has no idea you are running Tomcat or
using a Connector or that your connector is bound to 127.0.0.1.

I'll have a look at this because, as you say, it's quite surprising.

Unfortunately, most servers will be configured to listen to 0.0.0.0 (all
interfaces) and then ... we're back to using InetAddress.getLocalHost to figure
out what our "host name" is.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to