By mateeyow
Hi! I’m trying to bind my droplet’s anchor IP address to haproxy. Here’s my haproxy.cfg file:
global
maxconn 4096
debug
defaults
log global
mode tcp
option tcplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend www
bind $ANCHOR_IP:80
default_backend node-fedex
backend node-fedex
balance leastconn
server app-1 $BACKEND_IP_1:8080 check
server app-2 $BACKEND_IP_2:8080 check
I am using Docker’s official haproxy base image. And every time I run the container I get this error: Starting frontend www: cannot bind socket [10.15.0.40:80]. I can just bind the front-end with * but I just want it to bind to the anchor ip address then utilize the floating ip for high availability.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The Anchor IP, in this case 10.15.0.40, is not going to be available inside the container. By default Dockers are on their own bridge network. In the configuration file, you should bind to all interfaces inside the container.
global
maxconn 4096
debug
defaults
log global
mode tcp
option tcplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend www
bind *:80
default_backend node-fedex
backend node-fedex
balance leastconn
server app-1 $BACKEND_IP_1:8080 check
server app-2 $BACKEND_IP_2:8080 check
Then at run time, you will need to bind the container to the Anchor IP rather than the docker0 bridge network. In the example below example, I’ve built an image named “my-haproxy” from the simple Dockerfile:
FROM haproxy:1.5
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
To launch this container bound to the Anchor IP, run:
docker run --rm --name haproxy-test -p 10.15.0.40:80:80 my-haproxy
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.