Quantcast

Forward request from apache to specific web application

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Forward request from apache to specific web application

Salalam
I think my problem is very common, but I didn't find a solution.

I have Tomcat 5.5 with a web application. Let's say this application is deployed in the context 'mywebapp'. I can call the application with the url http://mydomain.com:8080/mywebapp.

But now i want to call the application via apache directly, e.g. with port 80 so that the url is just http://mydomain.com
I already configured mod_jk a little bit but my problem is: How do I forward the requests from apache to a specific webapplication in tomcat? My workers.properties has the following content:

ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

In httpd.conf I have the following entries:

JkMount /mywebapp ajp13
JkMount /mywebapp/* ajp13

This works fine with the url "http://mydomain.com/mywebapp" but I want to use the url "http://mydomain.com" and every request to this url should be forwarded to the "mywebapp"-application in tomcat.

What is missing?
Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Forward request from apache to specific web application

fredk2
hi,

in your tomcat server's webapp directory create a directory ./ROOT (in caps) and copy your application in there. Then restart tomcat.

In the workers.properties set the JkMount /*

see: http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

Alternatively you can set the context xml file mapping to / or add a ROOT.xml, see
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

Btw,with mod_jk 1.2.26 you can use replace:
JkMount /mywebapp ajp13
JkMount /mywebapp/* ajp13
with on line:  JkMount /mywebapp|/* ajp13

If you need to keep the tomcat uri /mywebapp, then you need to set a ProxyPass directive in apache (see the mod_proxy doc).

Rgrds, Fred



Salalam wrote
I think my problem is very common, but I didn't find a solution.

I have Tomcat 5.5 with a web application. Let's say this application is deployed in the context 'mywebapp'. I can call the application with the url http://mydomain.com:8080/mywebapp.

But now i want to call the application via apache directly, e.g. with port 80 so that the url is just http://mydomain.com
I already configured mod_jk a little bit but my problem is: How do I forward the requests from apache to a specific webapplication in tomcat? My workers.properties has the following content:

ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1

In httpd.conf I have the following entries:

JkMount /mywebapp ajp13
JkMount /mywebapp/* ajp13

This works fine with the url "http://mydomain.com/mywebapp" but I want to use the url "http://mydomain.com" and every request to this url should be forwarded to the "mywebapp"-application in tomcat.

What is missing?
Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Forward request from apache to specific web application

André Warnier
In reply to this post by Salalam
Salalam wrote:
> I think my problem is very common, but I didn't find a solution.
>
> I have Tomcat 5.5 with a web application. Let's say this application is
> deployed in the context 'mywebapp'. I can call the application with the url
> http://mydomain.com:8080/mywebapp.
> But now i want to call the application via apache directly, e.g. with port
> 80 so that the url is just http://mydomain.com

Well the first question to ask is whether you really need an Apache
front-end here.  You can have Tomcat listening directly on port 80 by
just changing the corresponding HTTP <Connector port=....> in your
server.xml.
And forget Apache and mod_jk in that case.

An Apache httpd+mod_jk front-end is justified if, apart from sending
some specific requests to Tomcat webapps, you want to do some other
things at the Apache level, that Tomcat cannot do as easily.  But if you
are sending everything to Tomcat anyway, then I don't see the point.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Forward request from apache to specific web application

Salalam
In reply to this post by fredk2
I'm deploying the application to the root context now ('/') and using a http-proxy in apache. With that config everthing works fine (Tomcat-Sessions, Cookies, Links).
Deploying the application in root seems to be easier than deploying it in an other context (regarding the apache-configuration).
Loading...