You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Andreas Dahlén <an...@dahlen.ws> on 2009/02/13 12:52:04 UTC

[users@httpd] Proxy needs to rewrite parameters in QueryString

Hi!

I've got a webapplication that the login functionality is placed on  
one server, and the
application is running on three other server (sort of loadbalancing).   
A parameter on a
successfull login tells which backendserver that should handle the  
requests. Everything
is placed behind a frontend that is acting as a proxy.

I'm running Apache on the frontend and the procy is configured according to;

ProxyPass /Login/ http://login.internal.com
ProxyPassReverse /Login/ http://login.internal.com
ProxyPass /backend1/ http://backend1.internal.com
ProxyPassReverse /backend1/ http://backend1.internal.com
ProxyPass /backend2/ http://backend2.internal.com
ProxyPassReverse /backend2/ http://backend2.internal.com
ProxyPass /backend3/ http://backend3.internal.com
ProxyPassReverse /backend3/ http://backend3.internal.com

A succefull LoginRequest is redirected by the Location-header
Location:  
http://login.internal.com?LoginSuccess?servername=http://backend1.internal.com

I need to rewrite "servername=http://backend1.internal.com" to
"servername=http://frontend.external.com/backend1"

I've tried to use Rewrite rules (from mod_rewrite) and ProxyHTMLURLMap (from
mod_proxy_html), but without success.

Any ideas on how to solve it?

/Andreas

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Proxy needs to rewrite parameters in QueryString

Posted by Nick Kew <ni...@webthing.com>.
On Wed, 18 Feb 2009 20:27:21 +0100
Andreas Dahlen <an...@dahlen.ws> wrote:

> The rewrite statements was wrong (I accidently changed one / to ?),
> should be "Location:
> http://login.internal.com/LoginSuccess?servername=http://backend1.internal.c
> om"
> 
> Since RewriteRules doesn't operate on what goes out, is there any
> other solution to operate on what goes out?

The first URL is of course dealt with by ProxyPassReverse.
For the second, see the docs for mod_headers.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Proxy needs to rewrite parameters in QueryString

Posted by Krist van Besien <kr...@gmail.com>.
On Wed, Feb 18, 2009 at 8:27 PM, Andreas Dahlen <an...@dahlen.ws> wrote:

> The rewrite statements was wrong (I accidently changed one / to ?), should
> be "Location:
> http://login.internal.com/LoginSuccess?servername=http://backend1.internal.c
> om"
>
> Since RewriteRules doesn't operate on what goes out, is there any other
> solution to operate on what goes out?

So basically once a user has authenticated himself thge tomcat
application generates the above redirect, right?. The browser then
will try to access this redirect.

Two things need to be done:
- The host part needs to be changed, so that the users receive a URL
that refers to the external host. Something like this might to this:

ProxyPassReverse /LoginSuccess http://login.internal.com/LoginSuccess

(ProxyPassReverse operates on redirects).

Now your users should get a redirect to
http://frontend.external.com/LoginSuccess?servername=http://backend1.internal.com
(Note, do you want to give away the internal structure of your site?)
The browser will now request this url, and since the host name part
points to your external server this host will receive it, and you can
use rewrites on this, as it is an incoming request.

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


SV: [users@httpd] Proxy needs to rewrite parameters in QueryString

Posted by Andreas Dahlen <an...@dahlen.ws>.
> > A succefull LoginRequest is redirected by the Location-header
> > Location:
http://login.internal.com?LoginSuccess?servername=http://backend1.internal.c
om
>
> This isn't a legal URL. Is this really what is returned?
>
> RewriteRules don't operate on what goes out, only on what comes in.
> ProxyHTMLURLMap doesn't operate on redirects. ProxyPassRevers does,
> but of course your redicrect must match.
>

The rewrite statements was wrong (I accidently changed one / to ?), should
be "Location:
http://login.internal.com/LoginSuccess?servername=http://backend1.internal.c
om"

Since RewriteRules doesn't operate on what goes out, is there any other
solution to operate on what goes out?

/Andreas


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Proxy needs to rewrite parameters in QueryString

Posted by Krist van Besien <kr...@gmail.com>.
On Fri, Feb 13, 2009 at 12:52 PM, Andreas Dahlén <an...@dahlen.ws> wrote:

> A succefull LoginRequest is redirected by the Location-header
> Location:
> http://login.internal.com?LoginSuccess?servername=http://backend1.internal.com

This isn't a legal URL. Is this really what is returned?

RewriteRules don't operate on what goes out, only on what comes in.
ProxyHTMLURLMap doesn't operate on redirects. ProxyPassRevers does,
but ofcourse your redicrect must match.

Krist


-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Proxy needs to rewrite parameters in QueryString

Posted by Krist van Besien <kr...@gmail.com>.
On Fri, Feb 13, 2009 at 12:52 PM, Andreas Dahlén <an...@dahlen.ws> wrote:

> A succefull LoginRequest is redirected by the Location-header
> Location:
> http://login.internal.com?LoginSuccess?servername=http://backend1.internal.com
>
> I need to rewrite "servername=http://backend1.internal.com" to
> "servername=http://frontend.external.com/backend1"

Something else: What do you hope to achieve here? If you just rewrite
one of the query parameters the redirect still points to an internal
server. (that is probably not available?)

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org