Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat - Host multiple sites?

 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm hosting a few sites on my Tomcat web server and right now I've written a script (in JavaScript) that redirects the user to the correct sub directory depending on the URL they gave. Does anyone know how I can do this in the Tomcat server.xml file? Thanks in advance.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you want is known as virtual hosting. There are 2 ways to do it.
1. Give each site its own unique IP address/port combination
2. Use the hostname-based targer determination that is only supported by HTTP 1.1 clients and higher.
I'm afraid I haven't attempted to do this in standalone Tomcat, so I'd have to RTFM. Using Apache/Tomcat, I setup a standard Apache <VirtualHost> directive block and translate to a unique Tomcat context for each site.
 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll have to go with option 2. Thanks for the direction. I'll take a look through docs and Google groups.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic