在 DocumentRoot 之外设置 Apache 目录时出现问题

在 DocumentRoot 之外设置 Apache 目录时出现问题

我正在尝试将 Apache 2.4.46 配置为提供 DocumentRoot 之外的目录。

这是我的 Apache 配置:

  <Directory /hab/svc/dispatcher/data/static>
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Require all granted
  </Directory>
  Alias /static/ "/hab/svc/dispatcher/data/static/"


<VirtualHost *:80>
   ServerName server.domain.com
   DocumentRoot /hab/svc/dispatcher/data/www-aem

  <Directory /hab/svc/dispatcher/data/www-aem>
    Options Indexes FollowSymLinks Includes
    Require all granted
    <IfModule disp_apache2.c>
      ModMimeUsePathInfo On
      SetHandler dispatcher-handler
    </IfModule>
  </Directory>

  <IfModule disp_apache2.c>
    DispatcherConfig /hab/svc/dispatcher/config/dispatcher.any
    DispatcherLogLevel info
    DispatcherLog /hab/svc/dispatcher/var/dispatcher.log
  </IfModule>
</VirtualHost>
### Some other rewrite stuff too

尽管已经设置了目录和别名,但我在请求 /static/chef-claes-c4b-3/index.html 时仍然遇到 404 错误,尽管该文件确实存在。

==> /hab/svc/dispatcher/var/logs/error.log <==
[Fri May 21 18:29:44 2021] [trace2] mod_rewrite.c(483): [client 10.100.109.27:50333] 10.100.109.27 - - [t1xaemdapp01.domain.com/sid#1fcaef8][rid#7fd5a8002bd0/initial] init rewrite engine with requested uri /static/chef-claes-c4b-3/index.html - HOST: t1xaemdapp01.domain.com
[Fri May 21 18:29:44 2021] [trace2] mod_rewrite.c(483): [client 10.100.109.27:50333] 10.100.109.27 - - [t1xaemdapp01.domain.com/sid#1fcaef8][rid#7fd5a8002bd0/initial] rewrite '/static/chef-claes-c4b-3/index.html' -> '/static/chef-claes-c4b-3/index.html?' - HOST: t1xaemdapp01.domain.com
[Fri May 21 18:29:44 2021] [trace2] mod_rewrite.c(483): [client 10.100.109.27:50333] 10.100.109.27 - - [t1xaemdapp01.domain.com/sid#1fcaef8][rid#7fd5a8002bd0/initial] local path result: /static/chef-claes-c4b-3/index.html - HOST: t1xaemdapp01.domain.com
[Fri May 21 18:29:44 2021] [trace2] mod_rewrite.c(483): [client 10.100.109.27:50333] 10.100.109.27 - - [t1xaemdapp01.domain.com/sid#1fcaef8][rid#7fd5a8002bd0/initial] prefixed with document_root to /hab/svc/dispatcher/data/www-aem/static/chef-claes-c4b-3/index.html - HOST: t1xaemdapp01.domain.com
[Fri May 21 18:29:44 2021] [trace1] mod_rewrite.c(483): [client 10.100.109.27:50333] 10.100.109.27 - - [t1xaemdapp01.domain.com/sid#1fcaef8][rid#7fd5a8002bd0/initial] go-ahead with /hab/svc/dispatcher/data/www-aem/static/chef-claes-c4b-3/index.html [OK] - HOST: t1xaemdapp01.domain.com
[Fri May 21 18:29:44 2021] [debug] mod_authz_core.c(815): [client 10.100.109.27:50333] AH01626: authorization result of Require all granted: granted - HOST: t1xaemdapp01.domain.com
[Fri May 21 18:29:44 2021] [debug] mod_authz_core.c(815): [client 10.100.109.27:50333] AH01626: authorization result of <RequireAny>: granted - HOST: t1xaemdapp01.domain.com

==> /hab/svc/dispatcher/var/logs/dispatcher.log <==
[Fri May 21 18:29:44 2021] [I] [pid 60487:tid 140554406979328] "GET /static/chef-claes-c4b-3/index.html" - blocked [domain_ca/-] 0ms

从日志中可以看到,Apache 正在 /hab/svc/dispatcher/data/www-aem/static/chef-claes-c4b-3/index.html 中查找 /static/chef-claes-c4b-3/index.html,这是一个已配置的目录。然后它委托给调度程序模块 disp_apache2.c,但该模块无法检索它,因此它返回 404。我不确定为什么它没有查看 /hab/svc/dispatcher/data/static/chef-claes-c4b-3/index.html,即使设置了别名。

有什么帮助吗?

相关内容