2017-05-26 4 views
1

J'ai la configuration suivante pour ma pile:haproxy pas de routage au service

api: 
    deployment_strategy: every_node 
    environment: 
    - 'DATABASE_URL=postgresql://.....' 
    - REDIS_HOST=redis 
    image: 'image/image:latest' 
    links: 
    - redis 
    ports: 
    - '5000:5000' 
lb: 
    image: 'dockercloud/haproxy:latest' 
    links: 
    - api 
    ports: 
    - '80:80' 
    privileged: true 
    roles: 
    - global 

et c'est la sortie haproxy

2017-05-26T12:00:51.752500376Z INFO:haproxy:dockercloud/haproxy 1.6.6 has access to the Docker Cloud API - will reload list of backends in real-time 
2017-05-26T12:00:51.752599249Z INFO:haproxy:dockercloud/haproxy PID: 5 
2017-05-26T12:00:51.883065649Z INFO:haproxy:=> Add task: Websocket open 
2017-05-26T12:00:52.884078353Z INFO:haproxy:=> Executing task: Websocket open 
2017-05-26T12:00:52.884105435Z INFO:haproxy:==========BEGIN========== 
2017-05-26T12:00:53.364820267Z INFO:haproxy:Linked service: API(d73c0091-ae4f-43b8-a3a8-ea11a276652e) 
2017-05-26T12:00:53.364872613Z INFO:haproxy:Linked container: API_1(3f981340-9b04-4105-8876-2ad1e5521f5c) 
2017-05-26T12:00:53.365695674Z INFO:haproxy:HAProxy configuration: 
2017-05-26T12:00:53.365705363Z global 
2017-05-26T12:00:53.365708753Z log 127.0.0.1 local0 
2017-05-26T12:00:53.365712075Z log 127.0.0.1 local1 notice 
2017-05-26T12:00:53.365715245Z log-send-hostname 
2017-05-26T12:00:53.365718228Z maxconn 4096 
2017-05-26T12:00:53.365721207Z pidfile /var/run/haproxy.pid 
2017-05-26T12:00:53.365724305Z user haproxy 
2017-05-26T12:00:53.365727513Z group haproxy 
2017-05-26T12:00:53.365730447Z daemon 
2017-05-26T12:00:53.365733783Z stats socket /var/run/haproxy.stats level admin 
2017-05-26T12:00:53.365736704Z ssl-default-bind-options no-sslv3 
2017-05-26T12:00:53.365746260Z ssl-default-bind-ciphers xxxxxx 
2017-05-26T12:00:53.365752089Z defaults 
2017-05-26T12:00:53.365755064Z balance roundrobin 
2017-05-26T12:00:53.365758035Z log global 
2017-05-26T12:00:53.365761046Z mode http 
2017-05-26T12:00:53.365764045Z option redispatch 
2017-05-26T12:00:53.365767032Z option httplog 
2017-05-26T12:00:53.365769951Z option dontlognull 
2017-05-26T12:00:53.365775842Z option forwardfor 
2017-05-26T12:00:53.365780388Z timeout connect 5000 
2017-05-26T12:00:53.365793420Z timeout client 50000 
2017-05-26T12:00:53.365796603Z timeout server 50000 
2017-05-26T12:00:53.365799585Z listen stats 
2017-05-26T12:00:53.365802356Z bind :1936 
2017-05-26T12:00:53.365805270Z mode http 
2017-05-26T12:00:53.365808233Z stats enable 
2017-05-26T12:00:53.365811235Z timeout connect 10s 
2017-05-26T12:00:53.365814235Z timeout client 1m 
2017-05-26T12:00:53.365817155Z timeout server 1m 
2017-05-26T12:00:53.365827005Z stats hide-version 
2017-05-26T12:00:53.365830160Z stats realm Haproxy\ Statistics 
2017-05-26T12:00:53.365833322Z stats uri/
2017-05-26T12:00:53.365837063Z stats auth stats:stats 
2017-05-26T12:00:53.365839909Z frontend default_port_80 
2017-05-26T12:00:53.365842760Z bind :80 
2017-05-26T12:00:53.365845760Z reqadd X-Forwarded-Proto:\ http 
2017-05-26T12:00:53.365848857Z maxconn 4096 
2017-05-26T12:00:53.365851745Z default_backend default_service 
2017-05-26T12:00:53.365854664Z backend default_service 
2017-05-26T12:00:53.365857581Z server API_1 10.7.0.2:5000 check inter 2000 rise 2 fall 3 
2017-05-26T12:00:53.365886854Z INFO:haproxy:Launching HAProxy 
2017-05-26T12:00:53.368391859Z INFO:haproxy:HAProxy has been launched(PID: 12) 
2017-05-26T12:00:53.368498117Z INFO:haproxy:===========END=========== 

quand j'accéder à l'adresse IP haproxy, je reçois ERR_CONNECTION_REFUSED sur Chrome et les journaux du service d'API sont vides, mais lorsque j'accède à l'haproxy sur le port 5000, alors oui, la requête touche mon API.
Je l'ai trouvé très bizarre, parce que je pensais que HAProxy ferait ce routage pour moi. Est-ce que je manque quelque chose? peut-être lier 80:5000?

Répondre

0

Cet exemple très simple travaille pour moi:

api: 
    image: nginx 

lb: 
    image: 'dockercloud/haproxy:latest' 
    links: 
    - api 
    ports: 
    - '80:80' 
    privileged: true 

(sans la partie roles parce que je ne suis pas à l'aide nuage docker)

... 
lb_1 | INFO:haproxy:HAProxy has been launched(PID: 13) 
lb_1 | INFO:haproxy:===========END=========== 
api_1 | 172.17.0.3 - - [26/May/2017:12:40:36 +0000] "GET/HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" "172.17.0.1" 
... 

lier peut-être 80: 5000?

Vous ne devriez pas. Il devrait suffire d'accéder à: 80 puis haproxy faire le reste.

+0

Je ne peux pas faire cela, puisque j'utilise dockercloud haproxy: https://github.com/docker/dockercloud-haproxy –

+0

Je viens de le réaliser. Laissez-moi passer en revue – Robert

+0

@LuizE. pouvez-vous vérifier cet exemple? – Robert