You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by roychan <em...@gmail.com> on 2008/09/15 04:55:47 UTC
Apache Frontend Proxy/URL Rewrite Tomcat
Hi Guru,
I am trying to setup an apache in front of a java application(Spring+Struts)
on tomcat so that
http://www.somedomain.com/ will route the traffic to
http://www.somedomain.com:8080/app/
I have tried the mod rewrite rule ^/(.*) http://localhost:8080/app/$1 [P]
but when user try to access a secure area, the Spring bounce the user back
to http://www.somedomain.com:8080/app/ (instead of port 80 root)
I have also tried the mod proxy to set up
ProxyPass / http://localhost:8080/app
ProxyPassReverse / http://localhost/app
But now the cookie is not set correctly
Then I tried to add proxyport="80" on the tomcat connector, this sorta work,
but it doesn't get rid of the /app/ part.
So what is the correct way to set this up? Please advise!
Thanks in advance!!
--
View this message in context: http://www.nabble.com/Apache-Frontend-Proxy-URL-Rewrite-Tomcat-tp19486621p19486621.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache Frontend Proxy/URL Rewrite Tomcat
Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message -----
From: "Alex Mestiashvili" <al...@biotec.tu-dresden.de>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, September 16, 2008 11:40 AM
Subject: Re: Apache Frontend Proxy/URL Rewrite Tomcat
> Johnny Kewl wrote:
>>
>> ----- Original Message ----- From: "Alex Mestiashvili"
>> <al...@biotec.tu-dresden.de>
>> To: "Tomcat Users List" <us...@tomcat.apache.org>
>> Sent: Monday, September 15, 2008 9:05 AM
>> Subject: Re: Apache Frontend Proxy/URL Rewrite Tomcat
>>
>>
>>> roychan wrote:
>>>> Hi Guru,
>>>>
>>>> I am trying to setup an apache in front of a java
>>>> application(Spring+Struts)
>>>> on tomcat so that
>>>> http://www.somedomain.com/ will route the traffic to
>>>> http://www.somedomain.com:8080/app/
>>>>
>>>> I have tried the mod rewrite rule ^/(.*) http://localhost:8080/app/$1
>>>> [P]
>>>>
>>>> but when user try to access a secure area, the Spring bounce the user
>>>> back
>>>> to http://www.somedomain.com:8080/app/ (instead of port 80 root)
>>>>
>>>> I have also tried the mod proxy to set up
>>>> ProxyPass / http://localhost:8080/app
>>>> ProxyPassReverse / http://localhost/app
>>>>
>>>> But now the cookie is not set correctly
>>>>
>>>> Then I tried to add proxyport="80" on the tomcat connector, this sorta
>>>> work,
>>>> but it doesn't get rid of the /app/ part.
>>>>
>>>> So what is the correct way to set this up? Please advise!
>>>>
>>>> Thanks in advance!!
>>>>
>>>>
>>>>
>>> Hi ,
>>>
>>> here is nice guide http://wiki.apache.org/cocoon/ApacheModProxy
>>>
>>> Alex
>>
>> Hi Alex... glad to see an Apache guru is here....
>> Alex when I look at those examples I dont see... a mapping at context
>> level
>>
>> ie they all seem to be doing...
>>
>> http://MyDomain/WebApp/Yada/Blah
>> to say
>> http://SomeTomcat:8080/WebApp/Yada/Blah
>>
>> which works...
>>
>> But
>>
>> http://MyDomain/Yada/Blah
>> to say
>> http://SomeTomcat:8080/WebApp/Yada/Blah
>>
>> has changed the context... and thats where it seems to fall down...
>>
>> I think even in the rewrite stuff there... they seem to be making sure
>> the contexts are the same...
>> ie.... the paths after the domain are the same...
>>
>> Do you think it is possible to map something thats looking for something
>> in the ROOT... to a webapp context...
>> Apache does that... but then cookies and context links go to its...
>>
>> For example if a test a cross over context... and say the JSP carries
>> relative links...
>> When tomact sends out the return page....
>>
>> The things are mapped relative to /webapp and not / on the next request
>> if you see what I mean...
>>
>> I'm not sure its possible to mix contexts... unless the tomcat site is
>> also designed for it...
>> ie tell the webapp that when it returns stuff... it must "pretend" its
>> own context is / not /webapp
>> and cookies.... it hurts my brain ;)
>>
>> Maybe I'm not seeing it... that example is not mixing contexts? (I think)
>>
>> ---------------------------------------------------------------------------
>>
>> HARBOR : http://www.kewlstuff.co.za/index.htm
>> The most powerful application server on earth.
>> The only real POJO Application Server.
>> See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
>> ---------------------------------------------------------------------------
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> Hi , I think you are right , I have been trying to get it working for 2
> hours today , but there is always something wrong .
>
> and behavior absolutely depends on webapp ie relative links , cookies and
> so on .
>
> I also find some interesting case
>
> I made an index.html page like this
> <html>
> <head>
> <title>test</title>
> </head>
> <frameset rows="100%" border="0">
> <frame src="/app/"
> title="Test"
> frameborder="0" />
> <noframes>
> <body>
> <p>
> Sorry your browser doesn't support frames.
> </p>
> </body>
> </noframes>
> </frameset>
> </html>
>
> and this is apache config
> <VirtualHost serv2:80>
> DocumentRoot /var/www/
> ServerName serv2
> <Directory /var/www/ >
> Options +Indexes
> Order allow,deny
> Allow from all
> </Directory>
> ServerSignature Off
> ProxyRequests Off
> ProxyErrorOverride On
> ProxyPreserveHost On
> RewriteEngine on
> RewriteRule ^/(index.html)?$ - [L]
> RewriteRule (^/[^/]+)(.*)$ http://serv8:8080/$1$2 [P,L]
> RewriteRule ^/(.*$) - [F,L]
> </VirtualHost>
>
> and this worked fine for one tomcat application , but did not work
> correctly for another (jamwiki).
>
> Alex
... have to take your word for it, anyone that can use RewriteRule has got
to be good ;)
So we got a rule of thumb... "dont cross contexts in ProxyPass to tomcat"...
until some guru shoots us down ;)
>From a practical point of view, its prob not a bad thing... not being able
to do... losing that mental map of uri context to webapp would probably
drive sdmin guys nuts anyway ;)
As I'm discovering Apache has some very powerful tools... quite capable of
getting anyone into trouble ;)
... thanks
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache Frontend Proxy/URL Rewrite Tomcat
Posted by Alex Mestiashvili <al...@biotec.tu-dresden.de>.
Johnny Kewl wrote:
>
> ----- Original Message ----- From: "Alex Mestiashvili"
> <al...@biotec.tu-dresden.de>
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Sent: Monday, September 15, 2008 9:05 AM
> Subject: Re: Apache Frontend Proxy/URL Rewrite Tomcat
>
>
>> roychan wrote:
>>> Hi Guru,
>>>
>>> I am trying to setup an apache in front of a java
>>> application(Spring+Struts)
>>> on tomcat so that
>>> http://www.somedomain.com/ will route the traffic to
>>> http://www.somedomain.com:8080/app/
>>>
>>> I have tried the mod rewrite rule ^/(.*)
>>> http://localhost:8080/app/$1 [P]
>>>
>>> but when user try to access a secure area, the Spring bounce the
>>> user back
>>> to http://www.somedomain.com:8080/app/ (instead of port 80 root)
>>>
>>> I have also tried the mod proxy to set up
>>> ProxyPass / http://localhost:8080/app
>>> ProxyPassReverse / http://localhost/app
>>>
>>> But now the cookie is not set correctly
>>>
>>> Then I tried to add proxyport="80" on the tomcat connector, this
>>> sorta work,
>>> but it doesn't get rid of the /app/ part.
>>>
>>> So what is the correct way to set this up? Please advise!
>>>
>>> Thanks in advance!!
>>>
>>>
>>>
>> Hi ,
>>
>> here is nice guide http://wiki.apache.org/cocoon/ApacheModProxy
>>
>> Alex
>
> Hi Alex... glad to see an Apache guru is here....
> Alex when I look at those examples I dont see... a mapping at context
> level
>
> ie they all seem to be doing...
>
> http://MyDomain/WebApp/Yada/Blah
> to say
> http://SomeTomcat:8080/WebApp/Yada/Blah
>
> which works...
>
> But
>
> http://MyDomain/Yada/Blah
> to say
> http://SomeTomcat:8080/WebApp/Yada/Blah
>
> has changed the context... and thats where it seems to fall down...
>
> I think even in the rewrite stuff there... they seem to be making sure
> the contexts are the same...
> ie.... the paths after the domain are the same...
>
> Do you think it is possible to map something thats looking for
> something in the ROOT... to a webapp context...
> Apache does that... but then cookies and context links go to its...
>
> For example if a test a cross over context... and say the JSP carries
> relative links...
> When tomact sends out the return page....
>
> The things are mapped relative to /webapp and not / on the next request
> if you see what I mean...
>
> I'm not sure its possible to mix contexts... unless the tomcat site is
> also designed for it...
> ie tell the webapp that when it returns stuff... it must "pretend" its
> own context is / not /webapp
> and cookies.... it hurts my brain ;)
>
> Maybe I'm not seeing it... that example is not mixing contexts? (I think)
>
> ---------------------------------------------------------------------------
>
> HARBOR : http://www.kewlstuff.co.za/index.htm
> The most powerful application server on earth.
> The only real POJO Application Server.
> See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
> ---------------------------------------------------------------------------
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
Hi , I think you are right , I have been trying to get it working for
2 hours today , but there is always something wrong .
and behavior absolutely depends on webapp ie relative links , cookies
and so on .
I also find some interesting case
I made an index.html page like this
<html>
<head>
<title>test</title>
</head>
<frameset rows="100%" border="0">
<frame src="/app/"
title="Test"
frameborder="0" />
<noframes>
<body>
<p>
Sorry your browser doesn't support frames.
</p>
</body>
</noframes>
</frameset>
</html>
and this is apache config
<VirtualHost serv2:80>
DocumentRoot /var/www/
ServerName serv2
<Directory /var/www/ >
Options +Indexes
Order allow,deny
Allow from all
</Directory>
ServerSignature Off
ProxyRequests Off
ProxyErrorOverride On
ProxyPreserveHost On
RewriteEngine on
RewriteRule ^/(index.html)?$ - [L]
RewriteRule (^/[^/]+)(.*)$ http://serv8:8080/$1$2 [P,L]
RewriteRule ^/(.*$) - [F,L]
</VirtualHost>
and this worked fine for one tomcat application , but did not work
correctly for another (jamwiki).
Alex
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache Frontend Proxy/URL Rewrite Tomcat
Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message -----
From: "Alex Mestiashvili" <al...@biotec.tu-dresden.de>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Monday, September 15, 2008 9:05 AM
Subject: Re: Apache Frontend Proxy/URL Rewrite Tomcat
> roychan wrote:
>> Hi Guru,
>>
>> I am trying to setup an apache in front of a java
>> application(Spring+Struts)
>> on tomcat so that
>> http://www.somedomain.com/ will route the traffic to
>> http://www.somedomain.com:8080/app/
>>
>> I have tried the mod rewrite rule ^/(.*) http://localhost:8080/app/$1 [P]
>>
>> but when user try to access a secure area, the Spring bounce the user
>> back
>> to http://www.somedomain.com:8080/app/ (instead of port 80 root)
>>
>> I have also tried the mod proxy to set up
>> ProxyPass / http://localhost:8080/app
>> ProxyPassReverse / http://localhost/app
>>
>> But now the cookie is not set correctly
>>
>> Then I tried to add proxyport="80" on the tomcat connector, this sorta
>> work,
>> but it doesn't get rid of the /app/ part.
>>
>> So what is the correct way to set this up? Please advise!
>>
>> Thanks in advance!!
>>
>>
>>
> Hi ,
>
> here is nice guide http://wiki.apache.org/cocoon/ApacheModProxy
>
> Alex
Hi Alex... glad to see an Apache guru is here....
Alex when I look at those examples I dont see... a mapping at context level
ie they all seem to be doing...
http://MyDomain/WebApp/Yada/Blah
to say
http://SomeTomcat:8080/WebApp/Yada/Blah
which works...
But
http://MyDomain/Yada/Blah
to say
http://SomeTomcat:8080/WebApp/Yada/Blah
has changed the context... and thats where it seems to fall down...
I think even in the rewrite stuff there... they seem to be making sure the
contexts are the same...
ie.... the paths after the domain are the same...
Do you think it is possible to map something thats looking for something in
the ROOT... to a webapp context...
Apache does that... but then cookies and context links go to its...
For example if a test a cross over context... and say the JSP carries
relative links...
When tomact sends out the return page....
The things are mapped relative to /webapp and not / on the next request
if you see what I mean...
I'm not sure its possible to mix contexts... unless the tomcat site is also
designed for it...
ie tell the webapp that when it returns stuff... it must "pretend" its own
context is / not /webapp
and cookies.... it hurts my brain ;)
Maybe I'm not seeing it... that example is not mixing contexts? (I think)
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache Frontend Proxy/URL Rewrite Tomcat
Posted by Alex Mestiashvili <al...@biotec.tu-dresden.de>.
roychan wrote:
> Hi Guru,
>
> I am trying to setup an apache in front of a java application(Spring+Struts)
> on tomcat so that
> http://www.somedomain.com/ will route the traffic to
> http://www.somedomain.com:8080/app/
>
> I have tried the mod rewrite rule ^/(.*) http://localhost:8080/app/$1 [P]
>
> but when user try to access a secure area, the Spring bounce the user back
> to http://www.somedomain.com:8080/app/ (instead of port 80 root)
>
> I have also tried the mod proxy to set up
> ProxyPass / http://localhost:8080/app
> ProxyPassReverse / http://localhost/app
>
> But now the cookie is not set correctly
>
> Then I tried to add proxyport="80" on the tomcat connector, this sorta work,
> but it doesn't get rid of the /app/ part.
>
> So what is the correct way to set this up? Please advise!
>
> Thanks in advance!!
>
>
>
Hi ,
here is nice guide http://wiki.apache.org/cocoon/ApacheModProxy
Alex
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Apache Frontend Proxy/URL Rewrite Tomcat
Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
----- Original Message -----
From: "roychan" <em...@gmail.com>
To: <us...@tomcat.apache.org>
Sent: Monday, September 15, 2008 4:55 AM
Subject: Apache Frontend Proxy/URL Rewrite Tomcat
>
> Hi Guru,
>
> I am trying to setup an apache in front of a java
> application(Spring+Struts)
> on tomcat so that
> http://www.somedomain.com/ will route the traffic to
> http://www.somedomain.com:8080/app/
>
> I have tried the mod rewrite rule ^/(.*) http://localhost:8080/app/$1 [P]
>
> but when user try to access a secure area, the Spring bounce the user back
> to http://www.somedomain.com:8080/app/ (instead of port 80 root)
>
> I have also tried the mod proxy to set up
> ProxyPass / http://localhost:8080/app
> ProxyPassReverse / http://localhost/app
>
> But now the cookie is not set correctly
>
> Then I tried to add proxyport="80" on the tomcat connector, this sorta
> work,
> but it doesn't get rid of the /app/ part.
>
> So what is the correct way to set this up? Please advise!
>
> Thanks in advance!!
Roychan...
Not sure off hand... ie it may be possible for Apache to fix the problem you
having... but look at this..
http://members.cox.net/midian/howto/apache+tomcat+proxy3.htm#3.1
and
http://confluence.atlassian.com/display/DISC/Using+Virtual+Hosts+on+both+Apache+and+Tomcat
Notice that they keeping the contexts and sub contexts the same...
ie... its not the port thats catching you its because
/webapp
becomes
/somethingelse
are not the same in cookies...
It may be possible to do something like set TC's cookies to
emptySessionPath
but personally I dont like it...
Tomcat doesnt know the context is been manipulated... thats the problem
As I said... maybe there is a way... but I think more conventional solutions
are to create a ROOT web app either as the web app, or one that redirects
request to that real context...
If there is a way to change contexts in ProxyPass... I've never seen it...
Apache will do it... but it seems to break webapps...
Also from a philamamamasophamical point of view... ROOT is very special...
typically in hosted sites its reserved for their use..
ie if you did manage to make a /webapp behave as the ROOT... what happens if
you need to do that with another webapp?
ie ROOT often "needs" to become a kind of site index...
when you have webapps for accounting, and salaries, and wiki's and.... they
cant all sit in ROOT... if you see what I'm trying to say...
A ROOT webapp is always going to end up being a "director", not a
specialist...
Have fun...
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org