Apache+mod_jk+tomcat: virtual hosts and rewriting URLs

Apache+mod_jk+tomcat: virtual hosts and rewriting URLs

Post by Jean-Francois Mac » Tue, 20 Mar 2001 19:40:47



Hello all,

Here is what I'm trying to do.
Two virtual hosts on my web server:
host1.mysite.com
host2.mysite.com

I configured Apache with mod_jk to forward some requests to Tomcat
(everything sent to /app for instance). What I'd like to do is rewrite the
URL within tomcat based on the VH the request comes from so that the
application running behind tomcat handles things differently (the idea is to
keep the URL the same way in the client browser).

For instance, client A asks for:
http://host1.mysite.com/app
Apache sends the request to Tomcat which communicates with the application
behind and sends back the result to Apache then the client.

client B asks for:
http://host2.mysite.com/app
Apache sends the request to Tomcat, tomcat sees it's in host2 VH and appends
"?host2=1" to the URL (http://host2.mysite.com/app?host2=1), communicates
with the application which based on this new parameter returns something
different. Data is sent back to Apache then the client.

=> Both clients A and B see only /app, when tomcat appends the "?host2=1"
parameter it would only be internal and transparent for users... Problem is
I have no clue how to do this :O I guess I have to add something to tomcat's
server.xml conf file in the VH context, but I don't know what...

<Host name="host2.mysite.com">
  Something here
</Host>

If anybody has the solution that would really be great :)

Thanks!

- Jeff

 
 
 

Apache+mod_jk+tomcat: virtual hosts and rewriting URLs

Post by Mark Johnso » Thu, 29 Mar 2001 08:26:41


I seem to recall that you will configure this in httpd.conf using the Alias
directive.

> Hello all,

> Here is what I'm trying to do.
> Two virtual hosts on my web server:
> host1.mysite.com
> host2.mysite.com

> I configured Apache with mod_jk to forward some requests to Tomcat
> (everything sent to /app for instance). What I'd like to do is rewrite the
> URL within tomcat based on the VH the request comes from so that the
> application running behind tomcat handles things differently (the idea is to
> keep the URL the same way in the client browser).

> For instance, client A asks for:
> http://host1.mysite.com/app
> Apache sends the request to Tomcat which communicates with the application
> behind and sends back the result to Apache then the client.

> client B asks for:
> http://host2.mysite.com/app
> Apache sends the request to Tomcat, tomcat sees it's in host2 VH and appends
> "?host2=1" to the URL (http://host2.mysite.com/app?host2=1), communicates
> with the application which based on this new parameter returns something
> different. Data is sent back to Apache then the client.

> => Both clients A and B see only /app, when tomcat appends the "?host2=1"
> parameter it would only be internal and transparent for users... Problem is
> I have no clue how to do this :O I guess I have to add something to tomcat's
> server.xml conf file in the VH context, but I don't know what...

> <Host name="host2.mysite.com">
>   Something here
> </Host>

> If anybody has the solution that would really be great :)

> Thanks!

> - Jeff


 
 
 

1. tomcat + virtual hosts + multiple tomcat jvm + mod_jk problem

Hi

i install apache 1.3.20, tomcat 3.2 with mod_jk. It works perfectly
even with virtual hosts and multiple tomcat jvm. But the problem I
want to solve having for every virtual host a different worker file,
because every virtual host has its own tomcat jvm. Is it possible ?
I tried to put JkWorkersFile into the <VirtualHosts> but then I get
the following error messages:
[ermeg] Error while opening workers

I hope anyone can help even, if there is no solution.

Stefan

2. user-mode port 0.58-2.4.18-36

3. apache mod_ssl mod_jk virtual hosts start problem

4. A makefile question?

5. Apache 1.3b2: Default Host and all virtual hosts serve only first virtual hosts pages?

6. trouble mounting ext2 as root

7. Apache mod_rewrite question, url rewrite, url forward

8. KDE knotes alarm?

9. Redirecting Virtual Host URL to real URL - HOW?

10. URL rewriting and Tomcat

11. Apache/Tomcat 4 and Virtual Hosts?

12. Mixing Apache Name Based Virtual Hosts and SSL Virtual Host

13. TOMCAT 3.2.3 on Linux with apache mod_jk