View previous topic :: View next topic |
Author |
Message |
nadin Tux's lil' helper
Joined: 05 Aug 2003 Posts: 103
|
Posted: Tue Sep 21, 2004 3:30 pm Post subject: apache + tomcat5 + vhosts |
|
|
Hello,
I already have apache and tomcat working together using mod_jk. I need help trying to get vhost to do the following
say I have a webapp called myapp, which is accessibale from mydomain.com (using apache vhosts)
so mydomain.com is being taken care of by apache, whereas mydomain.com/myapp is being taken care of by tomcat.
How do I setup vhosts such that
mycompany.com - > mydomain.com/myapp?
when I tried the following
DocumentRoot = /opt/tomca5/webapps/myapp
ServerName mycompany.com
I get a primessions denied error
Any idea?
Nadin |
|
Back to top |
|
|
tuxmin l33t
Joined: 24 Apr 2004 Posts: 838 Location: Heidelberg
|
Posted: Tue Sep 21, 2004 4:04 pm Post subject: |
|
|
You cannot access the tomcat webapps dir from apache directly. There are no html files in there! These are generated by tomcat and deliverd to apache either via ajp (mod_jk) or http.
To use http you have to make sure tomcat's http connector is configured (this should be true for the default installation).
you can verify by connecting to tomcat directly
http://tomcat.host:8080/myapp/
which should display your application.
Put the following lines in your httpd.conf
Code: |
ProxyPass /webapp/ http://tomcat.host:8080/myapp/
ProxyPassReverse /webapp/ http://tomcat.host:8080/myapp/
|
Now you can acces your tomcat app from apache by typing
http://apache.host/myapp/
For setting up jk I suggest you read
this document.
Alex!!! _________________ ALT-F4 |
|
Back to top |
|
|
nadin Tux's lil' helper
Joined: 05 Aug 2003 Posts: 103
|
Posted: Wed Sep 22, 2004 4:09 am Post subject: |
|
|
Thanks
I already have mod_jk setup.
I will try what you are saying shortly, but I do not believe my questions was very clear
if I have apache.com/myapp working, where myapp is a tomcat project,
i want to do
myapp.com
such that I would see the same as apache.com/myapp
just like I can do webmail.apache.com which would be the same as apache.com/mail
thanks
Nadin |
|
Back to top |
|
|
tuxmin l33t
Joined: 24 Apr 2004 Posts: 838 Location: Heidelberg
|
Posted: Wed Sep 22, 2004 8:12 am Post subject: |
|
|
OK,
if I get you right you have to setup a namebased virtual as described here
In your case it would look like this
Code: |
<VirtualHost 10.1.2.3>
ServerAdmin webmaster@host.foo.com
DocumentRoot /var /www/
ServerName myapp.com
ProxyPass / http://tomcat.host:8080/myapp/
ProxyPassReverse / http://tomcat.host:8080/myapp/
</VirtualHost>
|
I don't know if you can achieve this with jk. As far as I know you can only do
Code: |
JkMount /myapp worker-label
|
which means the mount point in the apache VFS must match the application context in your tomcat (this wasn't the case with JServ). Maybe you can use mod_alias or mod_rewrite to map / to /myapp. I never tried myself as it's normally not a good idea to map /
Hth,
Alex!!!
You could _________________ ALT-F4 |
|
Back to top |
|
|
nobspangle Veteran
Joined: 23 Mar 2004 Posts: 1318 Location: Manchester, UK
|
Posted: Wed Sep 22, 2004 4:40 pm Post subject: |
|
|
You could use a redirect something like
Code: | Redirect permanent http://myapp.com http://mydomain.com/myapp |
|
|
Back to top |
|
|
tuxmin l33t
Joined: 24 Apr 2004 Posts: 838 Location: Heidelberg
|
Posted: Thu Sep 23, 2004 9:14 am Post subject: |
|
|
Wouldn't you create a loop with that?
Alex!! _________________ ALT-F4 |
|
Back to top |
|
|
nobspangle Veteran
Joined: 23 Mar 2004 Posts: 1318 Location: Manchester, UK
|
Posted: Thu Sep 23, 2004 1:44 pm Post subject: |
|
|
I don't see why, your saying if someone types in http://myapp.com then redirect them to http://mydomain.com/myapp which forwards them on to the tomcat server. |
|
Back to top |
|
|
tuxmin l33t
Joined: 24 Apr 2004 Posts: 838 Location: Heidelberg
|
Posted: Thu Sep 23, 2004 6:51 pm Post subject: |
|
|
Of course you're right... I didn't notice the different host names _________________ ALT-F4 |
|
Back to top |
|
|
nadin Tux's lil' helper
Joined: 05 Aug 2003 Posts: 103
|
Posted: Sat Sep 25, 2004 2:14 am Post subject: |
|
|
Ok, when I tried the proxy pass thingy, it keep loopiing back and forth, when I removed the proxy pass reverse, it worked but when I go to
www.myapp.com
i get forwarded to www.domain.com/myapp
also, the brower url changes to it.
What I need is the for the user to only see www.myapp.com
and I was unable to get redirect directive to work at all.
Any ideas?
Thanks
Nadin |
|
Back to top |
|
|
nobspangle Veteran
Joined: 23 Mar 2004 Posts: 1318 Location: Manchester, UK
|
Posted: Sat Sep 25, 2004 7:48 am Post subject: |
|
|
In your workers2.properties you could try chaging the uri directive to
[uri:myapp.com/*]
I think that would serve anything asking for myapp.com from the webapps root in the tomcat directory.
But this isn't quite what you wanted because you can't have myapp1.com and myapp2.com pointing to different applications on the same server. |
|
Back to top |
|
|
|