You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by moh bad <mo...@sysnode.net> on 2007/05/11 01:10:12 UTC

[users@httpd] Rewrite "Location:" header.

Hi,

I wanted to modify the "Location:" header in 30X http responses using apache
2,
but failed to find a good solution.

In mod_headers I can unset the header and set a new one, but I can't use
a regular expression to modify his original value.

thanks for any idea.

Re: [users@httpd] Rewrite "Location:" header.

Posted by Krist van Besien <kr...@gmail.com>.
On 5/11/07, moh bad <mo...@sysnode.net> wrote:
> sorry, you're right I need to give some explanation
>
> I have an apache server behind a reverse proxy,
> The reverse-proxy handles ssl connexion and send the request to the apache
> server.
> But when the apache server send an redirect with a Location header, the
> reverse-proxy
> didn't rewrite the value of this header.
>
> 1/ So the client access for example https://www.toto.com
> 2/ the reverse proxy handles the ssl connexion, and send the request to
> apache server
>     So apache server receive a request on http://www.toto.com site
> 3/ Apache server send a redirect to http://www.toto.com/document
> 4/ the reverse proxy send to the client the redirect as-is without rewriting
> it to https://www.toto.com/document
>
> So, I wanted to solve this problem by rewriting the Location header before
> apache server send the
> response headers.

You need a "ProxyPassReverse statement.
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxypassreverse


-- 
krist.vanbesien@gmail.com
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] Rewrite "Location:" header.

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 11 May 2007 11:00:20 +0200
"moh bad" <mo...@sysnode.net> wrote:

> sorry, you're right I need to give some explanation

You have the standard reverse proxy setup.
See http://www.apachetutor.org/admin/reverseproxies

-- 
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] Rewrite "Location:" header.

Posted by Spil Oss <sp...@googlemail.com>.
On 11/05/07, moh bad <mo...@sysnode.net> wrote:
> sorry, you're right I need to give some explanation
>
> I have an apache server behind a reverse proxy,
> The reverse-proxy handles ssl connexion and send the request to the apache
> server.
> But when the apache server send an redirect with a Location header, the
> reverse-proxy
> didn't rewrite the value of this header.
>
> 1/ So the client access for example https://www.toto.com
> 2/ the reverse proxy handles the ssl connexion, and send the request to
> apache server
>     So apache server receive a request on http://www.toto.com site
> 3/ Apache server send a redirect to http://www.toto.com/document
> 4/ the reverse proxy send to the client the redirect as-is without rewriting
> it to https://www.toto.com/document
>
> So, I wanted to solve this problem by rewriting the Location header before
> apache server send the
> response headers.
>
> thank you.
>
> 2007/5/11, Nick Kew <ni...@webthing.com>:
> > On Fri, 11 May 2007 01:10:12 +0200
> > "moh bad" <mo...@sysnode.net> wrote:
> >
> > > Hi,
> > >
> > > I wanted to modify the "Location:" header in 30X http responses using
> > > apache 2,
> > > but failed to find a good solution.
> > >
> > > In mod_headers I can unset the header and set a new one, but I can't
> > > use a regular expression to modify his original value.
> >
> > Yes you can.  Header edit.  Provided you have an up-to-date version.
> >
> > But the usual reason for rewriting a Location is in a reverse proxy
> > situation, where there are better solutions.  As Joshua said, you
> > need to tell us what you're really doing.
> >
> >
> > --
> > Nick Kew
> >
> > Application Development with Apache - the Apache Modules Book
> > http://www.apachetutor.org/
> >
> >

Sounds like your reverse proxy is not an apache server? (SSL offload engine?)
This reverse proxy does not rewrite your Location header in the 302 response.

Ugly hack. You might solve this by setting ServerName
https://www.toto.com and enabling UseCanonicalName On, this will force
redirects to be pointing to https://www.toto.com.

---------------------------------------------------------------------
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] Rewrite "Location:" header.

Posted by moh bad <mo...@sysnode.net>.
sorry, you're right I need to give some explanation

I have an apache server behind a reverse proxy,
The reverse-proxy handles ssl connexion and send the request to the apache
server.
But when the apache server send an redirect with a Location header, the
reverse-proxy
didn't rewrite the value of this header.

1/ So the client access for example https://www.toto.com
2/ the reverse proxy handles the ssl connexion, and send the request to
apache server
    So apache server receive a request on http://www.toto.com site
3/ Apache server send a redirect to http://www.toto.com/document
4/ the reverse proxy send to the client the redirect as-is without rewriting
it to https://www.toto.com/document

So, I wanted to solve this problem by rewriting the Location header before
apache server send the
response headers.

thank you.

2007/5/11, Nick Kew <ni...@webthing.com>:
>
> On Fri, 11 May 2007 01:10:12 +0200
> "moh bad" <mo...@sysnode.net> wrote:
>
> > Hi,
> >
> > I wanted to modify the "Location:" header in 30X http responses using
> > apache 2,
> > but failed to find a good solution.
> >
> > In mod_headers I can unset the header and set a new one, but I can't
> > use a regular expression to modify his original value.
>
> Yes you can.  Header edit.  Provided you have an up-to-date version.
>
> But the usual reason for rewriting a Location is in a reverse proxy
> situation, where there are better solutions.  As Joshua said, you
> need to tell us what you're really doing.
>
>
> --
> 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] Rewrite "Location:" header.

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 11 May 2007 01:10:12 +0200
"moh bad" <mo...@sysnode.net> wrote:

> Hi,
> 
> I wanted to modify the "Location:" header in 30X http responses using
> apache 2,
> but failed to find a good solution.
> 
> In mod_headers I can unset the header and set a new one, but I can't
> use a regular expression to modify his original value.

Yes you can.  Header edit.  Provided you have an up-to-date version.

But the usual reason for rewriting a Location is in a reverse proxy
situation, where there are better solutions.  As Joshua said, you
need to tell us what you're really doing.


-- 
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] Rewrite "Location:" header.

Posted by Joshua Slive <jo...@slive.ca>.
On 5/10/07, moh bad <mo...@sysnode.net> wrote:
> Hi,
>
> I wanted to modify the "Location:" header in 30X http responses using apache
> 2,
> but failed to find a good solution.
>
> In mod_headers I can unset the header and set a new one, but I can't use
> a regular expression to modify his original value.

Your question is rather vague since it is hard to tell where the
Location header is coming from and at what stage you want it
rewritten.

Why don't you tell us what you are trying to accomplish?

Joshua.

---------------------------------------------------------------------
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