私は Kong を初めて使用し、Kong で手を汚そうとしています。kong (0.10) と Cassandra (最新) が別々の docker コンテナーで実行される環境があります。私の OS は macOS -Sierra 10.12.4 です。
ドッカーのカサンドラ:
docker run -d --name kong-database -p 9042:9042 cassandra:latest
ドッカーのコング:
docker run -d --name kong \
--link kong-database:kong-database \
-e "KONG_DATABASE=cassandra" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
-e "KONG_PG_HOST=kong-database" \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 7946:7946 \
-p 7946:7946/udp \
kong
Kong のドキュメントに従って、Kong Admin API を介して (IP を取得するための) 最初の API を追加しました。
curl -i -X POST \
--url http://localhost:8001/apis/ \
--data 'name=example-api' \
--data 'hosts=example.com' \
--data 'upstream_url=http://httpbin.org/ip'
HTTP/1.1 201 Created
Date: Wed, 19 Apr 2017 23:39:13 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Server: kong/0.10.1
{"http_if_terminated":true,"id":"9bab7ba9-f1f2-4b4d-aa9d-9966da17f94b","retries":5,"preserve_host":false,"created_at":1492645153409,"upstream_connect_timeout":60000,"upstream_url":"http:\/\/httpbin.org\/ip","upstream_send_timeout":60000,"https_only":false,"upstream_read_timeout":60000,"strip_uri":true,"name":"example-api","hosts":["example.com"]}
次のコマンドを実行してテストすると、
curl -i -X GET --url http://localhost:8000/ --header 'Host: example.com'
私はこれを得る、
HTTP/1.1 404 NOT FOUND
Date: Wed, 19 Apr 2017 23:40:48 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 233
Connection: keep-alive
Server: gunicorn/19.7.1
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Via: kong/0.10.1
X-Kong-Upstream-Latency: 590
X-Kong-Proxy-Latency: 93
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
ただし、直接アクセスするcurl http://httpbin.org/ip
と、IP が取得されます。
Kong を構成して同じ結果を得るにはどうすればよいですか?