简体   繁体   中英

VirtualHosting through Apache Tomcat 6.0

I am having the domain(any three) and want that it should run with the same port that the tomcat is having(8080). I have done upto that the adding the domain name and appbase in SERVER.XML .

    <Host name="www.hello.com"  appBase="hello_webapps"
        unpackWARs="true" autoDeploy="true"/>

<Host name="www.hi.com"  appBase="hi_webapps"
       unpackWARs="true" autoDeploy="true"/>

<Host name="www.bye.com"  appBase="bye_webapps"
        unpackWARs="true" autoDeploy="true"/>

and change in the host file of etc

 xxx.xxx.x.xx www.hello.com
 xxx.xxx.x.xx www.hi.com
 xxx.xxx.x.xx www.bye.com

XXX.XXX.X.XX is the ip address but by running www.hello.com:8080,it is giving the error 404.

There are tree essentials part TODO to establish virtual hosting in tomcat :

  • DNS configuration

You have to prepare your domain names and IP and configure your DNS server,the alternative is to use hosts file for test/dev .

  • Server.xml configuration

this step is to map deployed apps folder with the domain names that will be used when requesting the Tomcat server

example from official doc :

<Engine name="Catalina" defaultHost="ren">
    <Host name="ren"    appBase="renapps"/>
    <Host name="stimpy" appBase="stimpyapps"/>
</Engine>
  • Deploiement appliction folder

put the content of your app inside a folder called ROOT which will be inside the folder used in server.xml configuration (renapps in the example, the content will be in renapps/ROOT/ )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM