Testing Tomcat with Virtual Hosts
Posted
by Marty Pitt
on Server Fault
See other posts from Server Fault
or by Marty Pitt
Published on 2009-11-16T23:35:11Z
Indexed on
2010/03/15
23:10 UTC
Read the original article
Hit count: 424
I'm trying to test Tomcat virtual hosts on my dev machine (windows 7/Tomcat 6).
I'd like to have requests for localhost, test1.localhost and test2.localhost all route through to the same tomcat instance.
I've edited my hosts file to look as follows:
127.0.0.1 localhost
::1 localhost
127.0.0.1 test1.localhost
127.0.0.1 test2.localhost
And added modified the Engine in server.xml as follows:
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
<Host appBase="webapps" autoDeploy="true" name="localhost"
unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Alias>test1.localhost</Alias>
<Alias>test2.localhost</Alias>
</Host>
</Engine>
However, I'm getting a 404 when hitting test1.localhost:8080/myWebApp, although localhost:8080/myWebApp works fine.
I can ping test1.localhost fine.
What have I missed?
© Server Fault or respective owner