Select Page

Accessing a docker container behind apache’s reverse proxy bump into error:

Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /.

Reason: Error reading from remote server

Additionally, a 502 Bad Gateway error was encountered while trying to use an ErrorDocument to handle the request.

and logs reveals:

[proxy:error] [pid 3256] (111)Connection refused: AH00957: HTTP: attempt to connect to (*) failed

Docker was listening on as oppose to localhost and these two are not the same technically, apache translate http://localhost:PORT to a unix socket instead of TCP Scoket


ProxyPass / http://localhost:6001/
ProxyPassReverse / http://localhost:6001/

RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*)           ws://localhost:6001/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*)           http://localhost:6001/$1 [P,L]


ProxyPass /
ProxyPassReverse /

RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*)           ws://$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) $1 [P,L]