2016-12-24 4 views
2

Ich habe einen Cluster Docker Swarm auf AWS, die ich Waage mit HAProxy zu laden versuchen. Mein Setup, die hinter einem VPC ist sieht wie folgt aus:Load Balancing Docker Schwarm mit Ha Proxy

haproxy_server 10.10.0.10 
docker_swarm_master1 10.10.0.12 
docker_swarm_master2 10.10.0.13 
docker_swarm_worker3 10.10.0.14 

Mein einziger Tomcat-Container aktuell Master_1 ist und unten ist meine aktuelle HAProxy config Datei:

global 
log 127.0.0.1 local0 
    log 127.0.0.1 local0 notice 
    chroot /var/lib/haproxy 
stats socket /run/haproxy/admin.sock mode 660 level admin 
stats timeout 30s 
user haproxy 
group haproxy 
daemon 

defaults 
log global 
mode http 
option httplog 
option dontlognull 
    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 
maxconn 2000 

frontend servers 
    bind *:80 
    bind *:8443 ssl crt /etc/haproxy/certs/ssl.pem 
    default_backend hosts 



backend hosts 
    mode http 
    balance roundrobin 
    option httpchk OPTIONS/
    option forwardfor 
    option http-server-close 
    server swarm 10.10.0.12:8443 check inter 5000 

Ich bin in der Lage der Lage, das sehen index.html Seite im webapps-Verzeichnis, wenn ich die folgenden von der HAProxy Server:

curl -k https://10.10.0.12:8443/docs/index.html 

aber wenn ich versuche, die folgende curl c ommand unten, erhalte ich einen 503 Server nicht verfügbar Fehler

curl -k https://10.10.0.10:8443/docs/index.html 

Wer weiß, was ich falsch mache? Ich habe den halben Tag vergeblich damit verbracht.

EDIT

curl -XOPTIONS -vk https://10.10.0.10:8443/docs/index.html 

* Trying 10.10.0.10... 
* Connected to 10.10.0.10 (10.10.0.10) port 8443 (#0) 
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt 
* found 692 certificates in /etc/ssl/certs 
* ALPN, offering http/1.1 
* SSL connection using TLS1.2/ECDHE_RSA_AES_256_GCM_SHA384 
* server certificate verification SKIPPED 
* server certificate status verification SKIPPED 
* common name: *.secreturl.com (does not match '10.10.0.10') 
* server certificate expiration date OK 
* server certificate activation date OK 
* certificate public key: RSA 
* certificate version: #3 
* subject: OU=Domain Control Validated,CN=*.secreturl.com 
* start date: Sat, 27 Jun 2016 16:39:39 GMT 
* expire date: Tue, 11 Jun 2020 18:09:38 GMT 
* issuer: C=US,ST=Arizona,L=Scottsdale,O=GoDaddy.com\, Inc.,OU=http://certs.godaddy.com/repository/,CN=Go Daddy Secure Certificate Authority - G2 
* compression: NULL 
* ALPN, server did not agree to a protocol 
> OPTIONS/HTTP/1.1 
> Host: 10.10.0.10:8443 
> User-Agent: curl/7.47.0 
> Accept: */* 
> 
* HTTP 1.0, assume close after body 
< HTTP/1.0 503 Service Unavailable 
< Cache-Control: no-cache 
< Connection: close 
< Content-Type: text/html 
< 
<html><body><h1>503 Service Unavailable</h1> 
No server is available to handle this request. 
</body></html> 
* Closing connection 0 

curl -XOPTIONS -vk https://10.10.0.12:8443/docs/index.html 

* Trying 10.10.0.12... 
* Connected to 10.10.0.12 (10.10.0.12) port 8443 (#0) 
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt 
* found 692 certificates in /etc/ssl/certs 
* ALPN, offering http/1.1 
* SSL connection using TLS1.2/ECDHE_RSA_AES_256_GCM_SHA384 
* server certificate verification SKIPPED 
* server certificate status verification SKIPPED 
* common name: *.secreturl.com (does not match '10.10.0.10') 
* server certificate expiration date OK 
* server certificate activation date OK 
* certificate public key: RSA 
* certificate version: #3 
* subject: OU=Domain Control Validated,CN=*.secreturl.com 
* start date: Sat, 27 Jun 2016 16:39:39 GMT 
* expire date: Tue, 11 Jun 2020 18:09:38 GMT 
* issuer: C=US,ST=Arizona,L=Scottsdale,O=GoDaddy.com\, Inc.,OU=http://certs.godaddy.com/repository/,CN=Go Daddy Secure Certificate Authority - G2 
* compression: NULL 
* ALPN, server did not agree to a protocol 
> OPTIONS/HTTP/1.1 
> Host: 10.10.0.12:8443 
> User-Agent: curl/7.47.0 
> Accept: */* 
> 
< HTTP/1.1 200 OK 
< Server: Apache-Coyote/1.1 
< Allow: GET, HEAD, POST, PUT, DELETE, OPTIONS 
< Content-Length: 0 
< Date: Sat, 24 Dec 2016 18:39:27 GMT 
< 
* Connection #0 to host 10.10.0.12 left intact 
+0

Benötigen 'Frontend-Server'' Modus http'? – Rickkwa

+0

Das Hinzufügen von 'mode http' zu' frontend servers' oder sogar das Auskommentieren des 'mode http' im' backend' haben das Problem nicht behoben. – crusadecoder

Antwort

0

Wenn Sie eine 503 Service Not Available bekommen, dann nicht Ihre Gesundheit zu überprüfen.

Von Ihrer Konfiguration wird HAProxy OPTIONS http://10.10.0.12:8443/ verwenden, die fehlschlagen: Ihre Backend HTTPS-Verbindungen akzeptieren. Um das zu beheben, sagen HAProxy HTTPS zu verwenden:

server swarm 10.10.0.12:8443 check inter 5000 ssl verify none 

Hinweis: Sie können die Statistik-Seite mit

listen haproxy_admin 
    bind 127.0.0.1:22002 
    mode http 
    stats enable 
    stats uri/

ermöglichen kann, die helfen, wenn Sie weitere Fragen zu debuggen.

Edit:

Die Statistik Seite zeigt L7STS/404, das ist der http-Code HAProxy wird. HAProxy prüft derzeit https://10.10.0.12:8443/, während Sie https://10.10.0.12:8443/docs/index.html testen. Vielleicht sollten Sie diese URL in Ihrem Scheck verwenden:

option httpchk OPTIONS /docs/index.html 
+0

Danke David. Ich habe Ihre Empfehlung ausprobiert, aber immer noch die Fehlermeldung "503 Service Not Available" erhalten. Die Statistikseite zeigt erwartungsgemäß den Back-End-Schwarm-Dienst an. – crusadecoder

+0

Was sagt die 'LastChk'-Spalte auf der Stat-Seite? Wenn Sie 'curl -XOPTIONS -vk https: //10.10.0.12: 8443 /' versuchen, erhalten Sie eine '200 OK'? –

+0

Hallo David- Ich habe die erste Frage bearbeitet, um zu zeigen, was ich bekomme, wenn ich den Curl-Befehl ausführe, den Sie empfohlen haben. Ich habe es mit '10.10.0.10' versucht, was die Haproxy-IP und' 10.10.0.12' ist, die die Schwarm-IP ist. Letzteres ergab ein '200 ok'. Die 'LastChk' Spalte in den Statistiken zeigt' L7STS/404' in 4ms – crusadecoder