httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devendra Singh <dee....@gmail.com>
Subject Re: [users@httpd] Reverse Proxy and SSI from Back-End Apache
Date Wed, 09 Nov 2005 08:32:03 GMT
Hi,

Replying to my own post for reason of the problem and a typical solution.
On 11/9/05, Devendra Singh <dee.ess@gmail.com> wrote:
>
> On 11/9/05, Joshua Slive <jslive@gmail.com> wrote:
> >
> > On 11/8/05, Devendra Singh <dee.ess@gmail.com> wrote:
> > > But, the problem is that when I try to access
> > > http://ds.india.noida/dstest.html the SSI
> > > /mycomps/testsuccess.html also gets parsed from the Front Apache.
> >
> > Or, in other words, subrequests are not getting proxied.
>
>  Yes, SubRequests are not getting Proxied from SSI calls.
>
> > RewriteEngine On
> > > RewriteRule \.(gif|jpg|png|txt|css|js|ico|swf)$ [OR]
> > > RewriteRule !\/mycomps\/.* - [last]
> > > RewriteRule ^/(.*)$ http://ds.india.noida:8080/$1 [proxy]
> >
> > This looks quite bogus to me. As far as I know, there is no [OR]
> > option to RewriteRule. And you shouldn't be escaping forward slashes
> > in your regex. I'm surprised this works at all.
>
>  Yes, it works. However, if I comment the line:
> #RewriteRule \.(gif|jpg|png|txt|css|js|ico|swf)$ [OR]
>  that also suits my purpose.
>  About escaping of forward slashes, point noted, Thanks.
>
> On the original problem of subrequests and proxies, I don't recall
> > whether or not this works correctly. I imagine it should.
>
>  But, the original problem still remains. How do I force the subrequest
> due to SSI call from within a request getting served from Front Apache to go
> to Back Apache?
>
> Joshua.
> >
> > Thanks Joshua for your response.
>  But, I am still waiting for more expert hints.
>  DS
>

Problem Diagnosis -->
If I access http://ds.india.noida/mycomps/testsuccess.html directly it works
okay, i.e., gets served from Back Apache:
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:12:52 +051800] [
ds.india.noida/sid#8e829b8][rid#8f0bf78/initial] (2) init rewrite engine
with requested uri /mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:12:52 +051800] [
ds.india.noida/sid#8e829b8][rid#8f0bf78/initial] (3) applying pattern
'^/mycomps/testsuccess\.html$' to uri '/mycomps/testsuccess.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:12:52 +051800] [
ds.india.noida/sid#8e829b8][rid#8f0bf78/initial] (3) applying pattern
'^/(.*)$' to uri '/mycomps/testsuccess.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:12:52 +051800] [
ds.india.noida/sid#8e829b8][rid#8f0bf78/initial] (2) rewrite
/mycomps/testsuccess.html ->
http://ds.india.noida:8080/mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:12:52 +051800] [
ds.india.noida/sid#8e829b8][rid#8f0bf78/initial] (2) forcing
proxy-throughput with http://ds.india.noida:8080/mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:12:52 +051800] [
ds.india.noida/sid#8e829b8][rid#8f0bf78/initial] (1) go-ahead with proxy
request proxy:http://ds.india.noida:8080/mycomps/testsuccess.html [OK]

If I access http://ds.india.noida/dstest.html which has <!--#include
virtual="/mycomps/testsuccess.html" --> (dstest.html has to be served from
Front and /mycomps/testsuccess.html should be served from Back Apache, but
both are passed through):
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:13:27 +051800] [
ds.india.noida/sid#8e829b8][rid#8f16740/initial] (2) init rewrite engine
with requested uri /dstest.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:13:27 +051800] [
ds.india.noida/sid#8e829b8][rid#8f16740/initial] (3) applying pattern
'^/mycomps/testsuccess\.html$' to uri '/dstest.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:13:27 +051800] [
ds.india.noida/sid#8e829b8][rid#8f16740/initial] (1) pass through
/dstest.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:13:27 +051800] [
ds.india.noida/sid#8e829b8][rid#8f2e908/subreq] (2) init rewrite engine with
requested uri /mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:13:27 +051800] [
ds.india.noida/sid#8e829b8][rid#8f2e908/subreq] (3) applying pattern
'^/mycomps/testsuccess\.html$' to uri '/mycomps/testsuccess.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:13:27 +051800] [
ds.india.noida/sid#8e829b8][rid#8f2e908/subreq] (1) pass through
/mycomps/testsuccess.html

So, the Problem is that in case of "subreq" via SSI call, the mod_rewrite.c
is simply refusing to deal with a proxied subrequest (and thus SSI).

I checked the modules/mappers/mod_rewrite.c and found the following around
line 1828 (httpd-2.0.55):

/*
* Ignore this rule on subrequests if we are explicitly
* asked to do so or this is a proxy-throughput or a
* forced redirect rule.
*/
if (r->main != NULL &&
(p->flags & RULEFLAG_IGNOREONSUBREQ ||
p->flags & RULEFLAG_PROXY ||
p->flags & RULEFLAG_FORCEREDIRECT )) {
continue;
}

In my opinion (of limited knowledge of Apache internals) the line with
"RULEFLAG_PROXY" may be the culprit. I commented the line:

/* p->flags & RULEFLAG_PROXY || */

and recompiled the Front Apache. Voila, now its giving the desired effect of
rewriterule on subrequest via SSI.

So, now on accessing http://ds.india.noida/dstest.html, the result is:
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a2bf68/initial] (2) init rewrite engine
with requested uri /dstest.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a2bf68/initial] (3) applying pattern
'^/mycomps/.*$' to uri '/dstest.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a2bf68/initial] (1) pass through
/dstest.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a3a150/subreq] (2) init rewrite engine with
requested uri /mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a3a150/subreq] (3) applying pattern
'^/mycomps/.*$' to uri '/mycomps/testsuccess.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a3a150/subreq] (3) applying pattern
'^/(.*)$' to uri '/mycomps/testsuccess.html'
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a3a150/subreq] (2) rewrite
/mycomps/testsuccess.html ->
http://ds.india.noida:8080/mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a3a150/subreq] (2) forcing proxy-throughput
with http://ds.india.noida:8080/mycomps/testsuccess.html
10.216.204.64 <http://10.216.204.64> - - [09/Nov/2005:12:35:53 +051800] [
ds.india.noida/sid#99a29b8][rid#9a3a150/subreq] (1) go-ahead with proxy
request proxy:http://ds.india.noida:8080/mycomps/testsuccess.html [OK]

I would like to seek opinion of the expert list members / developers,
whether this modification is okay and would it have any bad impact somewhere
else?

Thanks for your time !

DS

--
Devendra Singh
S-4/A-116, Shalimar Garden Ext-II
Sahibabad, Ghaziabad (UP) - 201005 INDIA
Ph# +91+11-2637495
Mobile# +91-9818342483

Mime
View raw message