views:

421

answers:

3

Hi, new to JBoss and am configuring some applications. I know how to do this in apache webserver, but not using Jboss.

I have successfully deployed 3 applications on a redhat box, JBoss 4.2.

If my server is called fruit.mycompany.com, I can access the three apps this way:

http://fruit.mycompany.com:8080/quince
http://fruit.mycompany.com:8080/pineapple
http://fruit.mycompany.com:8080/lime

Next, I created three subdomains, which are aliases of the server fruit.

http://quince.mycompany.com
http://pineapple.mycompany.com
http://lime.mycompany.com

How can I get each subdomain to point at it's corresponding application?

I want http://quince.mycompany.com to actually open http://fruit.mycompany.com:8080/quince.

In apache, I would use the VirtualHost tag to point each subdomain to the correct Document Root. How do I do it with JBoss or Tomcat?

Can I do it with redirection ( does Tomcat have something like mod_rewrite )?

A: 

Have you looked at Tomcat Mod_jk http://tomcat.apache.org/connectors-doc/ ?

Langali
+2  A: 

Tomcat supports virtual hosts. You'll basically have to:

1) Change tomcat's "listen" port to 80 instead of 8080.

2) Modify tomcat's server.xml to list your servers:

<Engine name="Catalina" defaultHost="quince">
    <Host name="quince"    appBase="quince_apps"/>
    <Host name="pineapple" appBase="pineapple_apps"/>
    <Host name="lime"      appBase="lime_apps"/>
</Engine>

3) Move each application to 'ROOT' folder of corresponding "_apps" folder.

When I was in a similar situation, I chose to use Apache redirection instead; however I had Apache already serving static pages (public website).

ChssPly76
A: 

I gave up with Tomcat.

The situation became too complicated.
I have a web site running on port 80 already (on a separate instance of JBoss).
I have these three applications, quince, pineapple and lime running on their own JBoss instance on port 8080.

To solve my problem, I just wrote a javascript function on the index page of the website running on port 80.

I check location to see which domain is being called and then redirect to the appropriate website on port 8080.

The script looks something like this:

var whois=location+" ";
if (whois.indexOf("quince.mycompany.com") > -1)
{ 
    setTimeout('window.location.replace("http://quince.mycompany.com:8080/quince/");', 10);     
    exit;
}
if (whois.indexOf("lime.mycompany.com") > -1)
{ 
    setTimeout('window.location.replace("http://lime.mycompany.com:8080/lime/");', 10);     
    exit;
}
...
// otherwise redirect to the app running on port 80
setTimeout('window.location.replace("http://fruit.mycompany.com/otherapp/");', 10);

It's not exactly what I wanted, but at least my users now have a shortcut URL, and they don't have to remember port numbers: http://lime.mycompany.com redirects to -> http://lime.langara.bc.ca:8080/lime

jeph perro