ProxyPassMatch和Options + Indexes(mod_autoindex)

时间:2014-10-03 21:30:57

标签: php mod-proxy apache2.4 mod-autoindex

我有一个简单的Apache2.4和PHP-FPM设置,我正在尝试启用+ Indexes选项,但我得到404“找不到文件”。尝试访问没有索引文件的文件夹时,即使启用了自动索引。

这是我的vhost的一部分:

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

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

当我尝试访问http://domain.com/pub/时,我希望看到我放在那里的文件列表,但我得到错误404 Not Found。

我想知道它来自何处,因为ProxyPassMatch不应转发请求,因为查询中没有.php,所以接下来是目录索引,它查找不存在的index.php(404),但为什么然后mod_autoindex不干嘛?

当我删除ProxyPassMatch行时,autoindex工作正常,我看到列出的文件夹内容。 有什么想法吗?

1 个答案:

答案 0 :(得分:5)

我在这里找到了答案http://blog.famillecollet.com/post/2014/03/28/PHP-FPM-and-HTTPD-2.4-improvement

As the ProxyPassMatch directive is evaluated as 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.

所以我改变了我的vhost看起来像这样并且摆脱了ProxyPassMatch指令。

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

注意:此解决方案适用于Apache 2.4.9 +

我想知道是否有任何性能差异和方向?