You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Devendra Singh <de...@gmail.com> on 2005/11/08 15:30:51 UTC

[users@httpd] Reverse Proxy and SSI from Back-End Apache

Hi,
 I have a setup of Front / Back Apache Reverse Proxy. Front Apache is
running on port 80 and Back Apache is running on 8080. SSI OPTIONS is
enabled on both the Apache.
 I have a requirement that all files are to be served from the front Apache
except the /mycomps folder. The mycomps folder ScriptAlias. Requests to
/mycomps should go to Back Apache.
 Uptill this point everything is working as expected.
 That is:

If I try to access http://ds.india.noida/mycomps/testsuccess.html it gets
served from Back Apache as desired (confirmed from the logs) -- Good !

Now, I have another page "dstest.html" into the DocumentRoot folder which,
has a virtual include tag as:

<!--#include virtual="/mycomps/testsuccess.html" -->

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.

I wish that dstest.html should get served from Front Apache but
"/mycomps/testsuccess.html" should get parsed from Back Apache.

I would be thankful for any pointers please !

Here is my config:

Front Apache Virtual Host on port 80:
<VirtualHost 10.216.204.59 <http://10.216.204.59/>>
ServerAlias ds.india.noida www.ds.india.noida <http://www.ds.india.noida/>
ds.india
ServerName www.ds.india.noida <http://www.ds.india.noida/>
ServerAdmin dee.ess@gmail.com
DocumentRoot /home/www/html/jobs
ServerPath /jobs
ScriptAlias /mycomps/ "/home/www/html/mycomps/"
<Directory /home/www/html>
Options FollowSymLinks Includes
AddHandler server-parsed .html
AddOutputFilter INCLUDES .html
</Directory>
RewriteEngine On
RewriteRule \.(gif|jpg|png|txt|css|js|ico|swf)$ [OR]
RewriteRule !\/mycomps\/.* - [last]
RewriteRule ^/(.*)$ http://ds.india.noida:8080/$1 [proxy]
ProxyPassReverse / http://ds.india.noida:8080/
CustomLog /home/logs/ds_access_log combinedref env=!DONOTLOGIMAGE
</VirtualHost>

Back Apache Virtual Host on Port 8080:
<VirtualHost 10.216.204.59 <http://10.216.204.59/>>
ServerAlias ds.india.noida www.ds.india.noida <http://www.ds.india.noida/>
ds.india.noida
ServerName ds.india.noida
ServerAdmin dee.ess@gmail.com
DocumentRoot /home/www/html/jobs
ServerPath /jobs
<Directory /home/www/html>
Options FollowSymLinks Includes
AddHandler server-parsed .html
AddOutputFilter INCLUDES .html
</Directory>
</VirtualHost>

The entries for ds.india.noida www.ds.india.noida<http://www.ds.india.noida/>
ds.india are into my /etc/hosts file.

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

Re: [users@httpd] Reverse Proxy and SSI from Back-End Apache

Posted by Devendra Singh <de...@gmail.com>.
Hi,

On 11/10/05, Joshua Slive <js...@gmail.com> wrote:
>
> On 11/9/05, Devendra Singh <de...@gmail.com> wrote:
>
> > 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.
> >
>
> > 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?
>
> I don't think I'd call myself a mod_rewrite expert (in fact, you'd
> need to be a little insane to claim such a thing), but I see no
> problem with removing that check. You might want to file a bug report
> to have it removed permanently.
>
> Joshua.

  I have filed a Bug report (#37438).

Thanks,

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

Re: [users@httpd] Reverse Proxy and SSI from Back-End Apache

Posted by Joshua Slive <js...@gmail.com>.
On 11/9/05, Devendra Singh <de...@gmail.com> wrote:

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

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

I don't think I'd call myself a mod_rewrite expert (in fact, you'd
need to be a little insane to claim such a thing), but I see no
problem with removing that check.  You might want to file a bug report
to have it removed permanently.

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] Reverse Proxy and SSI from Back-End Apache

Posted by Devendra Singh <de...@gmail.com>.
Hi,

Replying to my own post for reason of the problem and a typical solution.
On 11/9/05, Devendra Singh <de...@gmail.com> wrote:
>
> On 11/9/05, Joshua Slive <js...@gmail.com> wrote:
> >
> > On 11/8/05, Devendra Singh <de...@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

Re: [users@httpd] Reverse Proxy and SSI from Back-End Apache

Posted by Devendra Singh <de...@gmail.com>.
On 11/9/05, Joshua Slive <js...@gmail.com> wrote:
>
> On 11/8/05, Devendra Singh <de...@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

Re: [users@httpd] Reverse Proxy and SSI from Back-End Apache

Posted by Joshua Slive <js...@gmail.com>.
On 11/8/05, Devendra Singh <de...@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.


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

On the original problem of subrequests and proxies, I don't recall
whether or not this works correctly.  I imagine it should.

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