Joost de Heer wrote:
RewriteCond %{REQUEST_URI} \.(cgi|cgir|php3|php)$
RewriteRule ^/(.*) http://www-modperl:8888/$1 [P]

That works fine in 1.3, but 2.0 and 2.2 fail. I've tried five different versions in a couple of different ways[*]:

<IfDefine PROXY1>
  # Picks the first DirectoryIndex entry, even if it doesn't exist.
  RewriteCond %{REQUEST_URI} \.(cgi|cgir|php3|php|ephtml)$
  RewriteRule ^/(.*)$ proxy:http://www-modperl:8888/$1
</IfDefine>

<IfDefine PROXY2>
# Returns unproxied contents if proxied item is an SSI: <!--#include virtual="blah.cgi" ->
  RewriteCond %{REQUEST_URI} \.(cgi|cgir|php3|php|ephtml)$
  RewriteRule ^/(.*)$ proxy:http://www-modperl:8888/$1 [NS]
</IfDefine>

<IfDefine PROXY3>
  # Passes all tests except the performance is horrendous.
  RewriteCond %{REQUEST_URI} /$
  RewriteCond %{LA-U:REQUEST_FILENAME} \.(cgi|cgir|php3|php|ephtml)$
  RewriteRule ^/(.*)$ proxy:http://www-modperl:8888/$1 [NS]

  RewriteCond %{REQUEST_URI} \.(cgi|cgir|php3|php|ephtml)$
  RewriteRule ^/(.*)$ proxy:http://www-modperl:8888/$1
</IfDefine>

<IfDefine PROXY4>
  # Returns unproxied file in all tests.
  <FilesMatch \.(cgi|cgir|php3|php|ephtml)$>
    RewriteRule ^/(.*)$ proxy:http://www-modperl:8888/$1
  </FilesMatch>
</IfDefine>

<IfDefine PROXY5>
  # "400 Bad Request" for all cases
  RewriteCond %{SCRIPT_FILENAME} \.(cgi|cgir|php3|php|ephtml)$
  RewriteRule ^/(.*)$ proxy:http://www-modperl:8888/$1 [PT]
</IfDefine>

Most of them work in certain cases. Only PROXY3 works in every case case I've tried, but it suffers from an explosion of subrequests that destroys performance under even moderate load. Some, like PROXY5 are obviously wrong but others, like PROXY4, make reasonable sense.

*: The tests were:

1) request for /foo/, where index.html had a SSI directive calling a proxied file.
2) Same as one, but requesting index.html directly, avoiding DirectoryIndex.
3) Requesting proxied file directly: /foo/bar.cgir
4) Requesting /foo/, where DirectoryIndex should choose index.cgir.

--
Mike Cramer
http://www.webkist.com/ | AIM: MikeWebkist

Reply via email to