Apache 反向代理 503 自定义页面不起作用

Apache 反向代理 503 自定义页面不起作用

我在主机上运行一个带有公开端口的 docker 容器8001。可以通过 访问主机localhost:8001。我还在端口 上运行一个 Apache 服务器8000

我的 Apache 配置如下(已编辑)

<VirtualHost *:8000>
        ProxyPreserveHost On

        DocumentRoot /var/www/html
        ErrorDocument 503 /index.html
        ProxyPass / http://0.0.0.0:8001/
        ProxyPassReverse / http://0.0.0.0:8001/

        ServerName localhost
</VirtualHost>

我想503在 docker 容器关闭时提供自定义错误页面,但我一直收到默认错误页面。

在此处输入图片描述

错误日志来自/var/log/apache2/error.log

[Sat May 23 18:07:25.126481 2020] [proxy:error] [pid 8769:tid 140193025681152] (111)Connection refused: AH00957: HTTP: attempt to connect to 0.0.0.0:8001 (0.0.0.0) failed
[Sat May 23 18:07:25.126524 2020] [proxy_http:error] [pid 8769:tid 140193025681152] [client 10.135.178.51:48456] AH01114: HTTP: failed to make connection to backend: 0.0.0.0
[Sat May 23 18:07:25.126577 2020] [proxy:error] [pid 8769:tid 140193025681152] (111)Connection refused: AH00957: HTTP: attempt to connect to 0.0.0.0:8001 (0.0.0.0) failed
[Sat May 23 18:07:25.126584 2020] [proxy_http:error] [pid 8769:tid 140193025681152] [client 10.135.178.51:48456] AH01114: HTTP: failed to make connection to backend: 0.0.0.0
[Sat May 23 18:07:33.957893 2020] [proxy:error] [pid 8769:tid 140193017288448] (111)Connection refused: AH00957: HTTP: attempt to connect to 0.0.0.0:8001 (0.0.0.0) failed
[Sat May 23 18:07:33.957942 2020] [proxy_http:error] [pid 8769:tid 140193017288448] [client 10.135.64.171:65456] AH01114: HTTP: failed to make connection to backend: 0.0.0.0
[Sat May 23 18:07:33.958006 2020] [proxy:error] [pid 8769:tid 140193017288448] (111)Connection refused: AH00957: HTTP: attempt to connect to 0.0.0.0:8001 (0.0.0.0) failed
[Sat May 23 18:07:33.958013 2020] [proxy_http:error] [pid 8769:tid 140193017288448] [client 10.135.64.171:65456] AH01114: HTTP: failed to make connection to backend: 0.0.0.0

当容器运行时,代理工作正常。我做错了什么?谢谢!

答案1

错误文档应该是文档根目录下的绝对文档

DocumentRoot /var/www/html
ErrorDocument 503 /index.html

您不需要否定ProxyPass ... !指令。

相关内容