![Apache 反向代理 503 自定义页面不起作用](https://linux22.com/image/752783/Apache%20%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%20503%20%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A1%B5%E9%9D%A2%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我在主机上运行一个带有公开端口的 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 ... !
指令。