Re: Weird interaction between mod_dir and [P] rewrites

2015-11-24 Thread Jose Kahan
Eric,

On Tue, Nov 24, 2015 at 01:37:09PM -0500, Eric Covener wrote:
> Tried DirectoryCheckHandler? It's a 2.2-vs-2.4 difference discovered a
> little too late to change by default.

Thank you very much. That fixed my issue. I wonder if it would be
interesting to add a note about this change in behavior and
the directive in [1].

Thank you again for your promt reply.

Cheers,

-jose

[1] http://httpd.apache.org/docs/2.4/upgrading.html


Re: Weird interaction between mod_dir and [P] rewrites

2015-11-24 Thread Eric Covener
Tried DirectoryCheckHandler? It's a 2.2-vs-2.4 difference discovered a
little too late to change by default.


Weird interaction between mod_dir and [P] rewrites

2015-11-24 Thread Jose Kahan
Hi, 

This is something that has changed in 2.4 compared to 2.2.

When I follow the simple scenario (attached file) in a fresh 
install of apache, mod_dir is affecting the first value of 
DirectoryIndex to my request before it is being proxied. 

In 2.2, I was used to browse "https:/example,com/foo/" and have 
this being proxied to a backend as "https://example2.com/bar/";. 
But now in 2.4.7, mod_dir is first converting "/foo/" to
"/foo/index.html" and then sending the proxy request as
"/bar/index.html".

Do you know if this is an intended feature or a bug? I would
expect the backend, and not the frontend, to decide what
it wants to add to a url ending by "/".

The code in mod_dir has changed and there's a section with a comment
saying that it steps aside when it detects it is inside a mod_rewrite
fixup. It seems to be missing a provision for proxy requests.

rbowen helped me test this against 2.4.17/fedora. I tested it against
2.4.10/debian jessie with the same result.

Thanks! Cheers.

-jose
Scenario for mod_dir and mod_rewrite bug

Tested against 2.4.17 in a fresh fedora install (Thanks rbowen!)

I have this setup

   /foo/.htaccess
   /bar/echo.php

Server runs in localhost.

1. In your apache config, make sure you have the DirectoryIndex directive
   e.g. 
DirectoryIndex index.html

2. Put the following php script under /bar/echo.php Its goal is to echo 
the request URI. You can do it with another script if you want:

[[
$ cat echo.php

]]

3. Put this .htaccess under /foo/.htaccess 
[[
$ cat .htaccess
RewriteEngine on
RewriteBase /foo
RewriteRule ^(.*)$ http://localhost/bar/echo.php/$1 [P,L]
]]

4. Try the test

   GET -Se http://localhost/foo/

If you get back: 

   Requested: ...echo.php/index.html
   # index.html is the first value of my DirectoryIndex directive

You see the bug, mod_dir added the first value of DirectoryIndex 
before doing the proxy request.