docker-archive / dockercloud-haproxy

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

Containers with multiple exposed ports #176

Closed patricknazar closed 6 years ago

patricknazar commented 7 years ago

I'm trying to get openproject:community:6 service behind a haproxy service using a custom VIRTUAL_HOST env variable.

By looking at the haxproxy logs on docker cloud, I can see that its adding both ports 80 and 5432 as a backend:

[proxy-1]2017-03-13T00:32:38.510003057Z backend SERVICE_OPENPROJECT [proxy-1]2017-03-13T00:32:38.510007499Z server OPENPROJECT_1 10.7.0.5:5432 check inter 2000 rise 2 fall 3 [proxy-1]2017-03-13T00:32:38.510012036Z server OPENPROJECT_1 10.7.0.5:80 check inter 2000 rise 2 fall 3

It seems it is causing frequent 502 errors. I've tried using VIRTUAL_HOST=domain.com:80 but it changes nothing. I've also tried EXCLUDE_PORTS=5432 also, nothing.

Thanks

tifayuki commented 7 years ago

@patricknazar

EXCLUDE_PORTS envvar is exactly what you needs. Did you set it in the linked service and redeploy the service?

patricknazar commented 7 years ago

@tifayuki I tried that but it didn't work, yeah I redeployed. Is that the right syntax EXCLUDE_PORTS=p1,p2,... ?

tifayuki commented 7 years ago

@patricknazar Yes. you can run the following two compse file and see the difference:

web:
  image: 'dockercloud/hello-world:latest'
  expose:
    - "8080"
    - "9000"
  environment:
    - VIRTUAL_HOST=example.org
lb:
  image: 'dockercloud/haproxy:latest'
  links:
    - web
  ports:
    - '80:80'
web:
  image: 'dockercloud/hello-world:latest'
  expose:
    - "8080"
    - "9000"
  environment:
    - VIRTUAL_HOST=example.org
    - EXCLUDE_PORTS=8080,9000
lb:
  image: 'dockercloud/haproxy:latest'
  links:
    - web
  ports:
    - '80:80'