前回
これまでの関連記事は、下記のとおり
今回
Mesh内部のbffコンテナから外部サイト(www.google.com)へリクエストしてみます。
構築したMeshは、下図のとおり、外部への通信を許可していません。
この状態で bff コンテナ内部から非SSLの外部サイト(http://www.google.com) にリクエストすると 404 エラーになります。
[root@ip-10-0-11-142 app]# curl -v http://www.google.com * About to connect() to www.google.com port 80 (#0) * Trying 172.217.5.228... * Connected to www.google.com (172.217.5.228) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www.google.com > Accept: */* > < HTTP/1.1 404 Not Found < date: Thu, 20 Aug 2020 23:08:03 GMT < server: envoy < content-length: 0 < * Connection #0 to host www.google.com left intact
Meshが、外部への通信を許可するように変更します。
cfnテンプレート(cfn_cloudmap.yml)を下記のように修正します。(赤枠部分を追加)
ローカルの cfnディレクトリで下記コマンドを実行してスタックを更新します。
$ make cfncmap CFNCMD=update-stack
下図のようにMeshの外部通信が許可されます。
この状態でbffコンテナから非SSLの外部サイト(http://www.google.com) にリクエストすると成功します。
[root@ip-10-0-11-142 app]# curl -v http://www.google.com * About to connect() to www.google.com port 80 (#0) * Trying 142.250.31.105... * Connected to www.google.com (142.250.31.105) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www.google.com > Accept: */* > < HTTP/1.1 200 OK < date: Thu, 20 Aug 2020 23:16:02 GMT < expires: -1 < cache-control: private, max-age=0 < content-type: text/html; charset=ISO-8859-1 < p3p: CP="This is not a P3P policy! See g.co/p3phelp for more info." < server: envoy < x-xss-protection: 0 < x-frame-options: SAMEORIGIN < set-cookie: 1P_JAR=2020-08-20-23; expires=Sat, 19-Sep-2020 23:16:03 GMT; path=/; domain=.google.com; Secure < set-cookie: NID=204=z5pfAFUusxuHEtARceeIZSO7H0bHu-Uh3RLMZ981Qd6VDPD1gczd0TJnLyosg2mCZ0E2X5-fhVA-fsgRom0lJN6sm65RxfFpPIT9NKgc0mkbC-Pcph6v-Hh0YLxuNDFD9TEc5Qpx_ZzkzKY_fBNIN-Hdd6geusBpWN7GREj9tPI; expires=Fri, 19-Feb-2021 23:16:03 GMT; path=/; domain=.google.com; HttpOnly < accept-ranges: none < vary: Accept-Encoding < x-envoy-upstream-service-time: 35 < transfer-encoding: chunked < ~省略~
次に、bffコンテナからSSLの外部サイト(https://www.google.com) にリクエストすると失敗します。
[root@ip-10-0-11-142 app]# curl -v https://www.google.com * About to connect() to www.google.com port 443 (#0) * Trying 142.250.31.99... * Connected to www.google.com (142.250.31.99) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG) * SSL received a record that exceeded the maximum permissible length. * Closing connection 0 curl: (35) SSL received a record that exceeded the maximum permissible length.
envoyに問題ありそうなので、
試しに、443ポートを envoy でプロキシしないように除外設定して試してみます。
cfnテンプレート(cfn_ecs_service_bff.yml)を下記のように修正します。(赤枠部分を追加)
ローカルの cfnディレクトリで下記コマンドを実行してスタックを更新します。
$ make cfnbff CFNCMD=update-stack
下図のようにenvoyが 443ポートを無視するように設定されます。
この状態でbffコンテナからSSLの外部サイト(https://www.google.com) にリクエストすると成功しました。
[root@ip-10-0-11-172 app]# curl -v https://www.google.com * About to connect() to www.google.com port 443 (#0) * Trying 172.217.8.4... * Connected to www.google.com (172.217.8.4) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 * Server certificate: * subject: CN=www.google.com,O=Google LLC,L=Mountain View,ST=California,C=US * start date: Aug 11 08:59:33 2020 GMT * expire date: Nov 03 08:59:33 2020 GMT * common name: www.google.com * issuer: CN=GTS CA 1O1,O=Google Trust Services,C=US > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www.google.com > Accept: */* > < HTTP/1.1 200 OK < Date: Thu, 20 Aug 2020 23:34:43 GMT < Expires: -1 < Cache-Control: private, max-age=0 < Content-Type: text/html; charset=ISO-8859-1 < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info." < Server: gws < X-XSS-Protection: 0 < X-Frame-Options: SAMEORIGIN < Set-Cookie: 1P_JAR=2020-08-20-23; expires=Sat, 19-Sep-2020 23:34:43 GMT; path=/; domain=.google.com; Secure < Set-Cookie: NID=204=BW-D1FoXk26Z9bujBzyePBIG64vHe__cUfPnJj7KQUowS6V3_EhEbRwlobbvBacWC7QuvAbxPGCwQHywGhPnbYR0kOUbxibZIvrmopndC7PtDigpNOsgs1uHFq0NysJANRVA8fzHvz4SKGi_5JoD5HYL0l-zXYjINQb__eha74w; expires=Fri, 19-Feb-2021 23:34:43 GMT; path=/; domain=.google.com; HttpOnly < Alt-Svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43" < Accept-Ranges: none < Vary: Accept-Encoding < Transfer-Encoding: chunked < ~省略~
[MEMO]
- envoy経由で外部サイトにSSL通信できないかもしれない。(下記URL参照)https://github.com/aws/aws-app-mesh-roadmap/issues/138