Load balancer not working at all

Was hoping to receive some help with this.

I have a ghost and wordpress stack, built from the catalog. I have wordpress running on port 5000, and ghost running on port 5001. I can visit each application by using the hostip:port.

I’ve set up a 3rd stack which contains the loadbalancer service. Here is how that is set up:


  - 80:80
  - ghost/ghost:ghost
  - wordpress/wordpress:wordpress
    io.rancher.loadbalancer.target.wordpress/wordpress: wordpress.dev=5000
    io.rancher.loadbalancer.target.ghost/ghost: ghost.dev=5001
  tty: true
  image: rancher/load-balancer-service
  stdin_open: true


root@593ced489b04:/# cat /etc/haproxy/haproxy.cfg
        log local0
        log local1 notice
        maxconn 4096
        maxpipes 1024
        chroot /var/lib/haproxy
        user haproxy
        group haproxy

        log     global
        mode    tcp
        option  tcplog
        option  dontlognull
        option  redispatch
        option http-server-close
        option forwardfor
        retries 3
        timeout connect 5000
        timeout client 50000
        timeout server 50000
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http

frontend b13b9617-cefe-4318-af84-27cd77e8c082_80_frontend
        bind *:80
        mode http

                acl 0_host hdr(host) -i wordpress.dev
                acl 0_host hdr(host) -i wordpress.dev:80
        use_backend b13b9617-cefe-4318-af84-27cd77e8c082_80_0_backend if 0_host
                acl 1_host hdr(host) -i ghost.dev
                acl 1_host hdr(host) -i ghost.dev:80
        use_backend b13b9617-cefe-4318-af84-27cd77e8c082_80_1_backend if 1_host

backend b13b9617-cefe-4318-af84-27cd77e8c082_80_0_backend
        mode http
        server d65bc1ec-4acd-4e3b-a9be-382a498c1d14

backend b13b9617-cefe-4318-af84-27cd77e8c082_80_1_backend
        mode http
        server 3c3d3a67-4137-45e4-abfe-8ed37bc97384

listen default
        bind *:42

When visiting ghost.dev or wordpress.dev I get a 503 Service Unavailable error. I’ve tried restarting everything and building from scratch on a new host. What have I done wrong?

The target ports 5001 and 5000 are not actually exposed/open on the ghost/wordpress containers. The load balancer goes directly to the containers of the service.

1 Like

In other words, you have to point your entry in the load balancer to the INTERNAL port the app is running on. The Ghost app from the catalog runs on 2368 internally so you would point your load balancer entry at that port.

1 Like

Thanks to the both of you, it’s working perfectly now.