You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2005/11/10 07:02:42 UTC

DO NOT REPLY [Bug 37438] New: - RewriteRule is ignored on a proxied subrequest via SSI call.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37438>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37438

           Summary: RewriteRule is ignored on a proxied subrequest via SSI
                    call.
           Product: Apache httpd-2.0
           Version: 2.0.55
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: dee.ess@gmail.com
                CC: dee.ess@gmail.com


Hi,

I am filing this bug report after discussion into the users list and a 
suggestion to file bug report (see: http://www.gossamer-
threads.com/lists/apache/users/299510).

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.

Here is my config:

Front Apache Virtual Host on port 80:
<VirtualHost 10.216.204.59>
   ServerAlias ds.india.noida www.ds.india.noida ds.india
   ServerName 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>
   ServerAlias ds.india.noida www.ds.india.noida ds.india.noida 
   ServerName 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>
</VirtualHost> 

The entries for ds.india.noida www.ds.india.noida ds.india are into 
my /etc/hosts file.

I enabled RewriteLogLevel to 9 and did further tests.

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 - - [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 - - [09/Nov/2005:12:12:52 +051800] [ds.india.noida/sid#8e829b8]
[rid#8f0bf78/initial] (3) applying pattern '^/mycomps/.*$' to 
uri '/mycomps/testsuccess.html'
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 - - [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 - - [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 - - [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 - - [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 - - [09/Nov/2005:12:13:27 +051800] [ds.india.noida/sid#8e829b8]
[rid#8f16740/initial] (3) applying pattern '^/mycomps/.*$' to uri '/dstest.html'
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 - - [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 - - [09/Nov/2005:12:13:27 +051800] [ds.india.noida/sid#8e829b8]
[rid#8f2e908/subreq] (3) applying pattern '^/mycomps/.*$' to 
uri '/mycomps/testsuccess.html' 
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 - - [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 - - [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 - - [09/Nov/2005:12:35:53 +051800] [ds.india.noida/sid#99a29b8]
[rid#9a2bf68/initial] (1) pass through /dstest.html
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 - - [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 - - [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 - - [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 - - [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 - - [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?

If this is okay, it may please be modified into the Apache 2.0.x series please.

Thanks,

Devendra Singh

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org