I'm trying to set up an apache server (run with Docker) to act as a load-balancing reverse proxy, but no matter what I try, I get the error
[proxy_balancer:error] [pid 8:tid 140013616056064] [client 172.17.0.1:39376] AH01171: balancer://cluster: No workers in balancer
Here's a minimum working example to demonstrate the problem:
Dockerfile:
FROM httpd:2.4
RUN for mod in \
slotmem_shm_module lbmethod_byrequests_module \
proxy_module proxy_http_module proxy_balancer_module; do \
sed -i "s/^#LoadModule \\($mod\\) /LoadModule \\1 /" conf/httpd.conf; \
done
RUN echo "Include conf/extra/test.conf" >> conf/httpd.conf
test.conf:
<Proxy "balance://cluster">
BalancerMember "http://www.google.com/"
BalancerMember "http://www.xkcd.com/"
</Proxy>
ProxyPass / balancer://cluster/
Run as docker run -it -p 80:80 -v $PWD/test.conf:/usr/local/apache2/conf/extra/test.conf proxy-test
Then try to retrieve http://localhost/
and the error appears in the server stderr.
I've tried putting it in a virtualhost, setting servername, putting in a ProxyPassReverse, putting the ProxyPass inside a <Location />
- none of it helps.
I figured it out - it's a typo. balance://cluster
should be balancer://cluster
.