2016-12-24 8 views
2

私はHAProxyを使用してロードバランスを試みているAWS上のDocker Swarmクラスタを持っています。 VPCの背後にある私のセットアップは、次のようになります。HAプロキシを使用したロードバランシングドッカースウォーム

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 

私の唯一のTomcatコンテナがmaster_1に、現在であり、以下に私の現在のHAProxy configファイルです:私は見ることができることができる午前

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 

webappsディレクトリ内のindex.htmlページ私はHAProxyサーバーから次ないとき:

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

しかし、私は次のようcurl Cをしようとすると、 ommand以下、私は誰もが私が間違っているのかを知る

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

503サーバー利用できないエラーが出ますか?私は半日を無駄に過ごしました。あなたが503 Service Not Availableを取得する場合

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

'フロントエンドサーバー'に 'モードhttp'が必要ですか? – Rickkwa

+0

残念ながら、 'frontend servers'に' mode http'を追加したり、 'backend'の' mode http'をコメントアウトしても問題は解決しませんでした。 – crusadecoder

答えて

0

、その後、あなたの健康チェックが失敗します。

設定から、HAProxyはOPTIONS http://10.10.0.12:8443/を使用します。これは失敗します。バックエンドはHTTPS接続を受け入れます。それを修正するには、HTTPSを使用するためにHAProxyを伝える:

server swarm 10.10.0.12:8443 check inter 5000 ssl verify none 

注意:あなたは、さらに問題のデバッグに役立つはずです

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

でのstatページを有効にすることができます。

編集:

STATページはL7STS/404を示し、それがHAProxyが取得するHTTPコードです。 https://10.10.0.12:8443/docs/index.htmlをテストしている間、HAProxyは現在https://10.10.0.12:8443/をチェックしています。おそらく、あなたはあなたの小切手でこのURLを使うべきです:

option httpchk OPTIONS /docs/index.html 
+0

Davidに感謝します。あなたのお勧めを試みましたが、 '503 Service Not Available'エラーメッセージが表示されました。 statsページには、バックエンドのswarmサービスが停止していることが予想されます。 – crusadecoder

+0

statページの 'LastChk'カラムの内容は何ですか? 'curl -XOPTIONS -vk https://10.10.0.12:8443 /'を試してみると、 '200 OK'が得られますか? –

+0

こんにちはDavid-あなたが推奨するcurlコマンドを実行したときの結果を示すために、最初の質問を編集しました。私はhaproxy IPである '10.10.0.10'とswarm IPである' 10.10.0.12 'を使って試しました。後者は '200 ok 'をもたらした。 statsの 'LastChk'カラムは' L7STS/404' in 4ms – crusadecoder

関連する問題