I am running a docker container with exposed port 8001
on my host. The host is reachable from the host with localhost:8001
. I am also running an Apache server on port 8000
.
My Apache configuration looks like this (edited)
<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>
I want to serve custom 503
error page when docker container is down, but I keep getting default error page.
Error logs from /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
When container is running, proxy works well.
What am I doing wrong? Thanks!
Best Answer
The error document should be absolute from the document root
You shouldn't need the negating
ProxyPass ... !
directive.