TOMCAT + JK + VIRTUAL HOST

E

eul-duv

Hi all !

i'm trying to create a kind of virtual hosting with tomcat:
my config:

1- my domain= www.mydomain.com
2- my webapp= /mywebapp
3- Directories:
/mywebapp/WEB-INF/
/mywebapp/images/
/mywebapp/admin/index.jsp
/mywebapp/index.jsp


if i do: www.mydomain.com:8080/mywebapp/index.jsp all is fine

3- my other domain= admin.mydomain.com

i woud like that "admin.mydomain.com:8080/index.jsp"
goes directly to: /mywebapp/admin/index.jsp

anyone have an idea ? thanks in advance !
 
A

Andoni

1st, set up your hosts in Tomcat using the <Host> tags in server.xml. Then
in each one create the context that makes your program work. Ignore the
fact that both hosts/contexts are pointing at the same actual .war file.

So. Alongside any current hosts have:

<Host name="www.mydomain.com" debug="0" appBase="webapps"
unpackWARs="false">
<Context path="" docBase="/mywebapp" debug="0">
</Context>
</Host>

<Host name="admin.mydomain.com" debug="0" appBase="webapps"
unpackWARs="false">
<Context path="" docBase="/mywebapp/admin" debug="0">
</Context>
</Host>

Let me know if this does not work for you and I'll see what's wrong.

Andoni.
 
A

Andoni

The following means that:

http://www.mydomain.com:8080/
http://www.mydomain.com:8080/admin/
and
http://admin.mydomain.com:8080/

Are all accessing the same thing.
then because they are all accessing the one web.xml file you cannot assign
different startup files to them. BUT If you really need the functionality
you are after you could at this point put in a JSP which checks the URL
forwards you to a different URL if(strUrl.indexOf("admin") != -1).

<Host name="www.mydomain.com" debug="0" appBase="webapps">
<Context path="" docBase="/mywebapp" debug="0">
<Context path-"/admin" docBase"/mywebapp">
</Context>
</Host>
<Host name="admin.mydomain.com" debug="0" appBase="webapps">
<Context path="" docBase="/mywebapp" debug="0">
</Context>
</Host>


But you have restricted yourself to doing this with a decision making page
by having the same web.xml / application for both admin and user app.

Let me know,

Andoni.
 

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
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top