简体   繁体   English

ProxyPassMatch 和选项 +Indexes (mod_autoindex)

[英]ProxyPassMatch and Options +Indexes (mod_autoindex)

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."我有一个简单的 Apache2.4 和 PHP-FPM 设置,我正在尝试启用 +Indexes 选项,但我得到 404“找不到文件”。 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.当我尝试访问http://domain.com/pub/ 时,我希望看到我放在那里的文件列表,但我收到错误 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?我想知道这是从哪里来的,因为 ProxyPassMatch 不应该转发请求,因为查询中没有 .php 所以接下来是目录索引,它查找不存在的 index.php(404)但是为什么 mod_autoindex 不起作用?

When I remove the ProxyPassMatch line the autoindex works just fine and I see the folder content listed.当我删除 ProxyPassMatch 行时,自动索引工作正常,我看到列出的文件夹内容。 Any ideas?有任何想法吗?

I found the answer here http://blog.famillecollet.com/post/2014/03/28/PHP-FPM-and-HTTPD-2.4-improvement我在这里找到了答案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:由于 ProxyPassMatch 指令在每个请求的最开始被评估:

  • AddType (for MultiView) or DirectoryIndex directives are not usable AddType(用于 MultiView)或 DirectoryIndex 指令不可用

  • right management per directory is not available每个目录的权限管理不可用

  • each Alias directive needs another proxy rule每个别名指令都需要另一个代理规则

The SetHandler directive, evaluated later, is much more flexible / usable.稍后评估的 SetHandler 指令更加灵活/可用。

So I changed my vhost to look like this and got rid of the ProxyPassMatch directive.所以我改变了我的虚拟主机看起来像这样并摆脱了 ProxyPassMatch 指令。

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

Note: this solution applies to Apache 2.4.9+注意:此解决方案适用于 Apache 2.4.9+

(I do wonder if there are any performance difference and in what direction?) (我确实想知道是否有任何性能差异以及在什么方向上?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM