【问题标题】:Custom Error Page not showing with using AJP Proxy with Apache将 AJP 代理与 Apache 一起使用时未显示自定义错误页面
【发布时间】:2019-11-19 19:37:07
【问题描述】:

我正在尝试在 Apache 上设置自定义 403 和 404 错误页面。

Server config is as follows:
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2019-04-03T13:22:37
Ubuntu 18.04.2 LTS

我使用 Apache 做 AJP 反向代理,如下:

    ProxyVia On
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass /app ajp://localhost:8009/share
    ProxyPassReverse /app ajp://localhost:8009/share

我的 ErrorDocument 代码如下:

    ErrorDocument 404 /cah-404.html
    ErrorDocument 403 /cah-403.html

现在,如果我通过浏览器访问上述应用程序,例如“https://server.xyz/app”,我会收到如下消息:

Forbidden
You don't have permission to access /app/ on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.4.29 (Ubuntu) Server at server.xyz Port 443

我的自定义错误页面位于 /var/www/html 这些页面的权限是 444

任何想法为什么会发生此错误? 我正在尝试从未经授权的 ISP 访问该页面。所以 Forbidden 显示很好 - 但它应该显示自定义禁止页面。

【问题讨论】:

    标签: apache tomcat reverse-proxy ajp


    【解决方案1】:

    我已经解决了这个问题: https://serverfault.com/questions/266924/apache-reverse-proxy-error-page-when-proxied-server-is-down

    答案的关键部分是“您应该使用 URL 指向您的 ErrorDocument,否则如果您使用文件系统引用,您将在尝试找到它时获得额外的 503。”

    所以现在,我的错误文档指令看起来像:

    ErrorDocument 404 http://server.xyz/cah-404.html
    ErrorDocument 403 http://server.xyz/cah-403.html
    

    【讨论】:

    • 更新 - 这个答案效果不太好。它适用于我在谷歌浏览器中的 Macbook。但在任何其他浏览器中都不起作用。在任何浏览器上我同事的 Linux 机器上也不起作用。不断提供无限重定向。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    • 2013-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-28
    相关资源
    最近更新 更多