eea / eea.docker.haproxy

HAProxy Docker image with docker links and reload support
https://registry.hub.docker.com/u/eeacms/haproxy/
57 stars 44 forks source link

wrong backend ports #24

Closed garrylachman closed 3 years ago

garrylachman commented 3 years ago

When i use different backend ports, the last port used for both ips/hostnames. backend1:3333 backend2:3334

in haproxy i see backend1 3334 backend2 3334

avoinea commented 3 years ago

@garrylachman The idea of this image is to be used like https://github.com/eea/eea.docker.haproxy/blob/master/docker-compose.yml in order to easily scale the number of backends:

docker-compose scale webapp=6

If your backends are docker containers also I don't see why would you need different ports for backend as you don't need to expose them on host.

Anyhow, if your backends still have different ports, you can add an extra layer of haproxy in between:

                 haproxy
                 /       \
     haproxy:3333         haproxy:3334
        /                       \
webapp:3333                       wbapp:3334
garrylachman commented 3 years ago

i use it to load balance between xmrig proxies, each one with different wallet.. so they have to be different

garrylachman commented 3 years ago

why just not parse ip:port list as it is

avoinea commented 3 years ago

@garrylachman Ok, let's see how you're running it, as I can see you can specify the backend and the port directly via BACKENDS environment variable like:

docker run -e BACKENDS="192.168.1.5:3333 192.168.1.6:3334" eeacms/haproxy

Can you please share your command / docker-compose?

avoinea commented 3 years ago

why just not parse ip:port list as it is

It should:

https://github.com/eea/eea.docker.haproxy/blob/c38dc9beb00615b00d5383b49cb5ac962ec730a7/haproxy/src/configure.py#L119-L121

avoinea commented 3 years ago

@garrylachman Ok, I think we found the issue:

https://github.com/eea/eea.docker.haproxy/blob/c38dc9beb00615b00d5383b49cb5ac962ec730a7/haproxy/src/configure.py#L130

garrylachman commented 3 years ago
version: "3.3"

services:
  proxy1:
    image: ninetom/xmrig-proxy
    ports:
      - 13333:13333
    command: "-b 0.0.0.0:13333 --workers ip -o gulf.moneroocean.stream:18192 -u -p proxy1 -k"

  proxy2:
    image: ninetom/xmrig-proxy
    ports:
      - 13334:13334
    command: "-b 0.0.0.0:13334 --workers ip -o gulf.moneroocean.stream:18192 -u -p proxy2 -k"

  haproxy:
    image: eeacms/haproxy
    depends_on:
    - proxy1
    - proxy2
    ports:
    - "13335:5000"
    - "1936:1936"
    environment:
      BACKENDS: "proxy2:13334 proxy1:13333"
      BACKENDS_MODE: tcp
      FRONTEND_MODE: tcp
      FROMTEND_PORT: 13335
      DNS_ENABLED: "true"
      LOG_LEVEL: "info"
      FALL: 10
haproxy_1  | [ALERT] 081/163600 (1) : Cannot open configuration file/directory /usr/local/etc/haproxy/haproxy.cfg : No such file or directory
proxy2_1   |  * ABOUT        xmrig-proxy/6.4.0-modify gcc/5.4.0
proxy2_1   |  * LIBS         libuv/1.8.0 OpenSSL/1.0.2g 
proxy2_1   |  * MODE         nicehash
proxy2_1   |  * POOL #1      gulf.moneroocean.stream:18192 algo auto
proxy2_1   |  * BIND #1      0.0.0.0:13334
proxy2_1   |  * COMMANDS     hashrate, connections, verbose, workers
proxy1_1   |  * ABOUT        xmrig-proxy/6.4.0-modify gcc/5.4.0
proxy1_1   |  * LIBS         libuv/1.8.0 OpenSSL/1.0.2g 
proxy1_1   |  * MODE         nicehash
proxy1_1   |  * POOL #1      gulf.moneroocean.stream:18192 algo auto
proxy1_1   |  * BIND #1      0.0.0.0:13333
proxy1_1   |  * COMMANDS     hashrate, connections, verbose, workers
backend_haproxy_1 exited with code 1
garrylachman commented 3 years ago

last version its worked, with wrong ports but started

valentinab25 commented 3 years ago

Fixed bug in latest and 1.8-1.6 - HAProxy official docker image changed the location of the configuration file