Location块内的Apache2.4 ProxyPass异常不起作用

Lia*_*ehy 5 reverse-proxy redirect apache-2.4

在尝试让 Let's Encrypt Certbot 在托管反向代理内容的本地服务器上工作时,我无法让本地异常在Location块内工作。httpd.conf片段:

SSLProxyEngine on
<Location "/">
    ProxyPass "https://internal.host/"
    ProxyPassReverse "https://internal.host/"
</Location>
Include /etc/apache2/vhosts.d/01_acme.include
Run Code Online (Sandbox Code Playgroud)

01_acme.include文件放在Location块的上方或下方没有任何影响。

01_acme.include文件:

<Location /.well-known/acme-challenge/>
    ProxyPass "!"
    Alias /run/acme/.well-known/acme-challenge
</Location>
Run Code Online (Sandbox Code Playgroud)

我在该目录中放置了一个名为date. 尝试检索此文件会导致无休止的 301 重定向,date/index.html/index.html/...直到达到客户端的重定向限制。日志显示这是在前端服务器上生成的,后端从未收到请求。

如果我用独立指令替换 Location 块,它会按预期运行:

Alias /.well-known/acme-challenge /run/acme/.well-known/acme-challenge
ProxyPass /.well-known/acme-challenge !
Run Code Online (Sandbox Code Playgroud)

根据ProxyPass文档,这种定义异常的方法应该有效 - 它非常符合该部分末尾提供的示例配置。这只是坏了,还是我错过了什么?

重定向可能是根本原因,但我在此范围内找不到任何可能引发 301 的重定向或重写指令,并且在.htaccess(没有)或配置文件中唯一提到的 index.html是目录索引,我已经尝试过明确禁用但Options -Indexes没有效果。

use*_*461 0

您在 .txt 中缺少尾部斜杠Alias。尾部斜杠必须匹配。

<Location /.well-known/acme-challenge/>
    ProxyPass "!"
    Alias /run/acme/.well-known/acme-challenge/
</Location>
Run Code Online (Sandbox Code Playgroud)