通过将AJP代理与Apache结合使用时,不显示“自定义错误”页面

时间:2019-07-10 08:13:16

标签: apache tomcat reverse-proxy ajp

我正在尝试在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访问该页面。因此,禁止显示是很好的-但它应该显示自定义的禁止页面。

1 个答案:

答案 0 :(得分:0)

我已使用以下方法解决了此问题: https://serverfault.com/questions/266924/apache-reverse-proxy-error-page-when-proxied-server-is-down

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

所以现在,我的errordocument指令看起来像:

ErrorDocument 404 http://server.xyz/cah-404.html
ErrorDocument 403 http://server.xyz/cah-403.html
相关问题