I am trying to debug a problem I’m having with my Tomcat server on a remote machine (Linode) and I need to experiment with multiple virtual hosts. However, I am not sure how to get my machine to treat certain domain names as local host. I want any request from my machine for either www.example.com and www.example.net to be routed back to localhost. But I can’t seem to find any relevant information on this. I though I had read something relevant on swerdna’s site but I can’t find it now.
Have you tried putting entries in your /etc/hosts file? What was the
result?
Good luck.
zak89 wrote:
> I am trying to debug a problem I’m having with my Tomcat server on a
> remote machine (Linode) and I need to experiment with multiple virtual
> hosts. However, I am not sure how to get my machine to treat certain
> domain names as local host. I want any request from my machine for
> either ‘Example Web Page’ (http://www.example.com) and ‘Example Web
> Page’ (http://www.example.net) to be routed back to localhost. But I
> can’t seem to find any relevant information on this. I though I had read
> something relevant on swerdna’s site but I can’t find it now.
>
> Any ideas?
>
>
> Thanks!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
You probably already have a line for 127.0.0.1… have you tried just
adding these to that line?
Good luck.
zak89 wrote:
> Perhaps I should elaborate on my attempts. I put the following entries
> in /etc/hosts:
>
>
> Code:
> --------------------
>
> 127.0.0.1 www.example.net
> 127.0.0.1 www.example.com
>
> --------------------
>
>
> then restarted the network:
>
>
> Code:
> --------------------
> rcnetwork restart
> --------------------
>
>
> However, pinging either domain name still gets me the “real” server’s
> response, rather than localhosts.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
I could, but the comments in the file suggest that /etc/hosts is field based, so how do I let it know that the additional names are for the same field?
I’m pretty sure I’ve done it this way before, and I thought the file was
just an IP followed by any number of “names”.
Good luck.
zak89 wrote:
> I could, but the comments in the file suggest that /etc/hosts is field
> based, so how do I let it know that the additional names are for the
> same field?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
But there is also a mechanism that tells where to look first for name solving. So when the first lookup is done to dns server and an answer is found nobody looks at /etc/hosts.
Now I thought that this is configured in /etc/nsswitch…conf
The line for dns in my nsswitch.conf is:
hosts: files mdns4_minimal [NOTFOUND=return] dns
What would mean: first look in the file (/etc/hosts in this case). This is what you want and what seems to be the default as installed. But you could check to be certain.