LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   using Apache as a front end to a running Tomcat instance (https://www.linuxquestions.org/questions/linux-server-73/using-apache-as-a-front-end-to-a-running-tomcat-instance-820978/)

tkmsr 07-20-2010 07:31 AM

using Apache as a front end to a running Tomcat instance
 
Hi,
I am having a problem.
I use Ubuntu 10.04 server edition.
Two computers on LAN one with Public Ip A other with local (Class C IP)say it B


With a third computer in same subnet I can access a TomCat application running on B as http://Ip of B:8080/application

I want to use A as a Reverse Proxy for this application to be reachable from internet.

So on Googling I came across some thing known as mod_ajp

I enabled that on my Server A as
a2enmod proxy
a2enmod proxy_ajp
a2enmod headers

but after that I am not able to understand as how do I define vhost to be able to forward HTTP request which come on A as
www.myserver.com/app
to B which I can see internally as http://Ip of B:8080/application so Tomcat on B handles this.

bathory 07-20-2010 08:12 AM

Hi again,
Try the usual reverse proxy setup on apache:
Code:

ProxyPass /app  http://x.x.x.x:8080/app
ProxyPassReverse /app  http://x.x.x.x:8080/app

Regards

tkmsr 07-20-2010 08:49 AM

:) Hi actually the reason I asked this problem is I had tried what you are saying.
When I had used it as
Code:

ProxyPass /app  http://x.x.x.x:8080/app
ProxyPassReverse /app http://x.x.x.x:8080/app

on internet if a client browser requested some thing as
http://www.mydomain.com/app/path/to/some/image/

I expect it to internally be forwarded as

Code:


 /app  http://x.x.x.:8080/app

in the URL where ever application at
is having an element in path as /app then it is able to connect but there
are many requests which are generated at B as
Code:

GET /library/skin/default/portal.css
GET /portal/styles/portalstyles.css
GET /library/js/jquery.js

which are not having /app word in URL path so what happens is
if a requests is
http://www.mydomain.com/app/path/to/some/image/
it is served but if a request for

http://www.mydomain.com/app
is generating a URL as
http://www.mydomain.com/library/js/jquery.js
then the request dies at A itself since /library would not be Proxied to B.
My problem is the application is generating how many URL's like this that is not known to me.
Some one suggested me to use Apache as a front end to Tomcat so I googled across and came some links.
Tried some configurations which I think were wrong so wanted if this way some one has used and they can share how they did it.

bathory 07-20-2010 09:13 AM

Can't you configure the backend application, so that it's aware it's running behind a proxy?
Quote:

Some one suggested me to use Apache as a front end to Tomcat so I googled across and came some links.
Recently I had to setup a jira server (that is a tomcat running a custom app named jira), using apache as a reverse proxy and came into this page. For my case it was of no use, but I hope that it helps in yours

Regards

tkmsr 07-20-2010 09:32 AM

Quote:

Originally Posted by bathory (Post 4039486)
Can't you configure the backend application, so that it's aware it's running behind a proxy?

Well even I am searching for this.
Thanks for your link I will try it.


All times are GMT -5. The time now is 04:39 PM.