Testing Tomcat with Virtual Hosts
- by Marty Pitt
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?