You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Anthony Browne <aa...@widernet.org> on 2005/08/10 18:35:42 UTC

[users@httpd] [P] flag in mod_rewrite

            What does the [P] flag in mod_rewrite use to proxy requests? For
example, the only way to rewrite a request and proxy it is with the [P] flag
after the rewrite. I haven't been able to find a way to proxy requests after
a rewrite with mod_rewrite without using the [P] flag. Apache seems to apply
rules from mod_proxy before rules from mod_rewrite and, if a mod_proxy rule
applies, the mod_rewrite rules are skipped. Why is this the case and is
there a way around this?


Re: [users@httpd] [P] flag in mod_rewrite

Posted by Joshua Slive <js...@gmail.com>.
On 8/11/05, Anthony Browne <aa...@widernet.org> wrote:
>         The reason I need to proxy with mod_proxy after a rewrite is
> because I need to check and see if the request can be satisfied from
> our static cache of mirrored sites using mod_rewrite's -s and -d
> flags. If the request cannot be satisfied from the filesystem, the
> request must be rewritten again back to normal and proxied to the
> remote host. We want it to appear to the user as though they are
> receiving the request from the actual server and to have it
> reflect as much in the users address bar.
>         This works for most requests that require an actual proxy, but
> it does not work for those sites requiring basic, NTLM, or https
> authentication. We're not concerned with https because our server
> won't support it, but we do need basic and NTLM to work. When using
> ProxyRequests on, this works with all three forms of authentication,
> but the rewrite rules are skipped.
>         The ideal situation would be to rewrite and use ProxyRequests
> on in the event of an actual proxy, rather than with the [P] flag.
> It appears that the [P] flag only has limited access to mod_proxy's
> functionality.
>         So, this is why we need to do this. Our server is complicated
> and pretty unconventional. I can elaborate further about the goal
> and intent of our server if necessary.

Ah.  So your problem is that you are trying to do a forward proxy,
whereas the [P] flag of mod_rewrite creates a reverse proxy (like the
ProxyPass directive).  I've never played much with forward proxies, so
I can't really help you here.  I don't know whether or not it is
possible to manipulate forward proxy requests with mod_rewrite.  I'd
tend to doubt it.  One idea would be to look at mod_cache and
mod_disk_cache rather than trying to role your own cache with
mod_rewrite.

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


RE: [users@httpd] [P] flag in mod_rewrite

Posted by Anthony Browne <aa...@widernet.org>.
	The reason I need to proxy with mod_proxy after a rewrite is 
because I need to check and see if the request can be satisfied from
our static cache of mirrored sites using mod_rewrite's -s and -d
flags. If the request cannot be satisfied from the filesystem, the 
request must be rewritten again back to normal and proxied to the 
remote host. We want it to appear to the user as though they are 
receiving the request from the actual server and to have it 
reflect as much in the users address bar.
	This works for most requests that require an actual proxy, but
it does not work for those sites requiring basic, NTLM, or https 
authentication. We're not concerned with https because our server 
won't support it, but we do need basic and NTLM to work. When using
ProxyRequests on, this works with all three forms of authentication, 
but the rewrite rules are skipped.
	The ideal situation would be to rewrite and use ProxyRequests 
on in the event of an actual proxy, rather than with the [P] flag. 
It appears that the [P] flag only has limited access to mod_proxy's
functionality.
	So, this is why we need to do this. Our server is complicated 
and pretty unconventional. I can elaborate further about the goal 
and intent of our server if necessary.

-----Original Message-----
From: Joshua Slive [mailto:jslive@gmail.com] 
Sent: Wednesday, August 10, 2005 11:58 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] [P] flag in mod_rewrite

On 8/10/05, Anthony Browne <aa...@widernet.org> wrote:
>             What does the [P] flag in mod_rewrite use to proxy requests?
For
> example, the only way to rewrite a request and proxy it is with the [P]
flag
> after the rewrite. I haven't been able to find a way to proxy requests
after
> a rewrite with mod_rewrite without using the [P] flag. Apache seems to
apply
> rules from mod_proxy before rules from mod_rewrite and, if a mod_proxy
rule
> applies, the mod_rewrite rules are skipped. Why is this the case and is
> there a way around this? 

There is no way around this that I know of besides manually messing
with module ordering, which is not usually a good idea.

But the real question is: why would you need to do this?  If you are
already processing a request with mod_rewrite then it is usually much
clearer if you use mod_rewrite to ask for the proxying as well. 
mod_rewrite doesn't actually do the proxying, but simply handes it
back to mod_proxy.  So, for example, the following two directives are
essentially identical in effect (except perhaps in very special
cases):

ProxyPass /foo http://bar
RewriteRule ^/foo(.*) http://bar$1 [P]

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





---------------------------------------------------------------------
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] [P] flag in mod_rewrite

Posted by Joshua Slive <js...@gmail.com>.
On 8/10/05, Anthony Browne <aa...@widernet.org> wrote:
>             What does the [P] flag in mod_rewrite use to proxy requests? For
> example, the only way to rewrite a request and proxy it is with the [P] flag
> after the rewrite. I haven't been able to find a way to proxy requests after
> a rewrite with mod_rewrite without using the [P] flag. Apache seems to apply
> rules from mod_proxy before rules from mod_rewrite and, if a mod_proxy rule
> applies, the mod_rewrite rules are skipped. Why is this the case and is
> there a way around this? 

There is no way around this that I know of besides manually messing
with module ordering, which is not usually a good idea.

But the real question is: why would you need to do this?  If you are
already processing a request with mod_rewrite then it is usually much
clearer if you use mod_rewrite to ask for the proxying as well. 
mod_rewrite doesn't actually do the proxying, but simply handes it
back to mod_proxy.  So, for example, the following two directives are
essentially identical in effect (except perhaps in very special
cases):

ProxyPass /foo http://bar
RewriteRule ^/foo(.*) http://bar$1 [P]

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