3

I have a simple setup with Apache2.4 and PHP-FPM and I am trying to enable +Indexes option but I get 404 "File not found." when trying to access a folder that doesn't have an index file even when autoindex is enabled.

Here's part of my vhost:

#php
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/fpm/fatal.sock|fcgi://

#super public directory with Indexes!
<Location /pub>
    Options +Indexes
    IndexOptions +FancyIndexing
</Location>

When I try to access http://domain.com/pub/ I expected to see a list of files I put there but instead I get error 404 Not Found.

I wonder where this comes from since ProxyPassMatch shouldn't forward the request because there is no .php in the query so next is directory index which looks for index.php which doesn't exists (404) but why then mod_autoindex doesn't work?

When I remove the ProxyPassMatch line the autoindex works just fine and I see the folder content listed. Any ideas?

nforced
  • 361
  • 3
  • 14

1 Answers1

6

I found the answer here http://blog.famillecollet.com/post/2014/03/28/PHP-FPM-and-HTTPD-2.4-improvement

As the ProxyPassMatch directive is evaluated at the very beginning of each request:

  • AddType (for MultiView) or DirectoryIndex directives are not usable

  • right management per directory is not available

  • each Alias directive needs another proxy rule

The SetHandler directive, evaluated later, is much more flexible / usable.

So I changed my vhost to look like this and got rid of the ProxyPassMatch directive.

<FilesMatch \.php$>
  SetHandler "proxy:unix:/var/run/fpm/fatal.sock|fcgi://"
</FilesMatch>

Note: this solution applies to Apache 2.4.9+

(I do wonder if there are any performance difference and in what direction?)

MeSo2
  • 450
  • 1
  • 7
  • 18
nforced
  • 361
  • 3
  • 14
  • It may be worth mentioning that with the proposed solution you will also need to add: SetHandler application/x-httpd-php-source As in the linked article. – dadasign Jan 19 '15 at 09:30
  • I suspect the performance is slightly less in this version because, as your quote indicates, `ProxyPassMatch` skips several steps such as directory right management. I doubt the differences are large enough to be significant. – Philip Couling Dec 01 '16 at 18:29