Hi Alex,
The "serverAddress" property indeed does comparisons based on the
numerical IP address. There are some convenience static methods on
VirtualHost:
- getLocalHostAddress()
- getIpAddress(String domain)
This should get clarified in the Javadocs too.
Best regards,
Jerome
2007/8/17, Alex Milowski <[EMAIL PROTECTED]>:
> On 8/16/07, Alex Milowski <[EMAIL PROTECTED]> wrote:
> > Currently you can set a server's bind address by name (e.g. "localhost")
> > but when you set the server address on a VirtualHost instance, the
> > wrong thing happens (e.g. nothing works).
> >
> > I think the problem is that the server's address is in numeric form
> > internally. For example, in the case of "localhost", you are comparing
> > "localhost" to "127.0.0.1"--which is always going to fail.
>
> I've been able to fix this by doing:
>
> try {
> InetAddress addr =
> InetAddress.getByName(iface.getAddress());
> String saddr = addr.toString();
> saddr = saddr.substring(saddr.indexOf('/')+1);
> getLogger().info("Restricting "+host.getName()+" to
> address "+saddr);
> vhost.setServerAddress(saddr);
> } catch (UnknownHostException ex) {
> getLogger().severe("Cannot resolve host name
> "+iface.getAddress());
> }
>
> Should I have to pass in the resolved address ?
>
> --Alex Milowski
>