IP Based Virtual Hosting / Tomcat

S

skijor

Hi,
I use Tomcat 6.0.10 as a stand-alone web application server (not
sitting behind Apache httpd). I host several domains on a single
physical host using name-based virtual hosting set up in server.xml.
I need to enable ssl for one of the domains. I understand I can no
longer use name-based hosting with ssl.

Is there a way to enable IP based hosting in tomcat directly or do I
now have to run tomcat behind apache for ip hosting / ssl.?

Thanks
 
S

skijor

Is there a way to enable IP based hosting in tomcat directly

yes. Minimally add a DNS entry to your hosts file:

10.0.1.200 my.subdomain.com

then, add useIPVHosts="true" to your SSL HTTP/1.1 connector

keep the Named Based Virtual Host the same:

<Host name="my.subdomain.com" appBase="webapps/myApp-1.0.0"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="." debug="1"/>
</Host>

Note: If you are going to host more than one domain over https, you
will need to create another ethernet device with
a new LAN IP (for unix, google the 'ifconfig' command). Then add the
new ip/domain name mapping to the host file:

10.0.1.201 my.subdomain2.com
 
W

wheresjim

That's great! I am not using this for SSL, but rather I want a second
webapp folder for staging and want to use the same named URL but with
different IP adresses and choose which webapps folder to use based on
IP, regardless of name.

So just as you said, I added useIPVHosts="true" to my connector such
that:

<Connector port="80" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25"
maxSpareThreads="75"
redirectPort="443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"
useIPVHosts="true"/>

Then I added set the virtual hosts such that:

<Host name="deploy.mywebserver.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"> ... </Host>

<Host name="staging.mywebserver.com" appBase="webapps-staging"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false"> ... </Host>

Then I made the following additions to my hosts file:

192.168.12.201 staging.mywebserver.com
[my outside ipaddress] deploy.mywebserver.com

Now whenever I test, I just set my client's hosts file to:

192.168.12.201 deploy.mywebserver.com

And I can test without disrupting my deployment server.

Thanks!

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top