docker-archive / dockercloud-haproxy

HAproxy image that autoreconfigures itself when used in Docker Cloud
https://cloud.docker.com/
652 stars 181 forks source link

Adding external backends #162

Closed crazyfrozenpenguin closed 7 years ago

crazyfrozenpenguin commented 7 years ago

I'm trying to run the following scenario in OSX using Docker native (no docker-machine).

  1. In my system (out of docker) I run a web server to listen in external IP and port 8080.
  2. In Docker I run another web server and haproxy using:
version: "2"

services:

  web:
    image: web:latest
    ports:
      - "8081"

web-lb:
    image: dockercloud/haproxy:1.6.2
    ports:
      - 80:80
    depends_on:
      - web
    links:
      - web
    environment:
      - "ADDITIONAL_BACKENDS_EXWEB=backend default_service, server exweb external.ip:8080 check inter 2000 rise 2 fall 3"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Notes: . I've confirmed that my haproxy container can connect to my external.ip address

. I've tried many different combinations for ADDITIONAL_BACKENDS:

And the same without: "_EXWEB"

I'm sure I'm missing something, and help would be appreciated. This is to be used in the next few days in an AWS deployment. Any ideas?

lnogol commented 7 years ago

try ADDITIONAL_BACKEND_EXWEB=server exweb external.ip:8080 check inter 2000 rise 2 fall 3

tifayuki commented 7 years ago

@crazyfrozenpenguin

Other than the backend, you also need to add a related frontend. However, the evvar EXTRA_FRONTEND_SETTINGS_<PORT> only adds setting to an existing frontend. The current implementation of the script doesn't create a new frontend, if there is no frontend listening to that port.

dev-lusaja commented 7 years ago

Hi, im have a code example for this question in docker-compose version 1 and 2.

https://github.com/dev-lusaja/Docker-Cloud-HAproxy

I hope this is useful