2016-11-25 7 views
0

RESTとAPIゲートウェイで新しく追加されました。KongにAPIを追加

私はCassandraをデベロッパーマシンにインストールしましたが、私はAPI(スプリングブートアプリケーション)を追加しようとしていますが、ドキュメントを読んで私はそれを動作させるのに苦労しています。

マイAPI:

http://ff-nginxdev-01:9003/fund-information-services/first-information/fund/{fundId} 

私は

http http://ff-nginxdev-01:9003/fund-information-services/first-information/fund/630 

    HTTP/1.1 200 
    Content-Type: application/json;charset=UTF-8 
    Date: Fri, 25 Nov 2016 14:47:30 GMT 
    Transfer-Encoding: chunked 
    X-Application-Context: application:9003 

    { 
     "assetSplit": { 
      "allocationHistories": [ 
       { 
        "key": { 
         "asset": { 
          "description": "Other Far East", 
          "id": 18 
         }, 
         "assetSplit": "09", 
         "effectiveDate": 1430348400000 
        }, 
    ...... 
    ...... 

を実行したときにすべてが罰金を見て、私は、JSONメッセージを取得することができますよ。香港でAPIを追加

http POST http://ff-nginxdev-01:8001/apis/ name=fund-information upstream_url=http://ff-nginxdev-01:9003/ request_path=/fund-information-services 


    HTTP/1.1 201 Created 
    Access-Control-Allow-Origin: * 
    Connection: keep-alive 
    Content-Type: application/json; charset=utf-8 
    Date: Fri, 25 Nov 2016 14:39:45 GMT 
    Server: kong/0.9.4 
    Transfer-Encoding: chunked 

    { 
     "created_at": 1480084785000, 
     "id": "fdcc76d7-e2a2-4816-8f27-d506fdd32c0a", 
     "name": "fund-information", 
     "preserve_host": false, 
     "request_path": "/fund-information-services", 
     "strip_request_path": false, 
     "upstream_url": "http://ff-nginxdev-01:9003/" 
    } 

テストコングAPIゲートウェイ:

http http://ff-nginxdev-01:8000/fund-information-services/first-information/fund/630 

HTTP/1.1 502 Bad Gateway 
Connection: keep-alive 
Content-Type: text/plain; charset=UTF-8 
Date: Fri, 25 Nov 2016 14:44:33 GMT 
Server: kong/0.9.4 
Transfer-Encoding: chunked 

An invalid response was received from the upstream server 

私は何かが欠けています知っているが、それは私には明確ではありません。

+0

nginxのおそらく 'ff-nginxdev-01'を解決できません。それを解決できるリゾルバを使用するようにNginxを適切に設定してください(あなたはKongの設定ファイルを使用することができます)。理想的にはFQDNを使用してください。 – thibaultcha

答えて

0

デフォルトでは、動的SSLプラグインは特定のSSL証明書をAPIのrequest_hostにバインドします。 request_pathをAPIに定義するだけで、request_pathを使用するとSSLプラグインが適用されません。

あなたはそれがでているようである理由を理解するために多くを読むことができます:私はあなたがどのようにプロキシAPIをするのに約読むべきだと思う、あなたの要求が動作するようにするにはthis issue

Proxy Reference

ここに私の解決策があります

方法1:あなたの問題のための変更 "strip_request_path" 真

"strip_request_path": true 

この方法によを想定Uは方法2 request_host最初

が指定されていませんでした。代わりにrequest_host

"request_host" : "your_api" 

を使用すると、その後、あなたのリクエストヘッダに、あなたはこのrequest_hostを追加する必要があります

例要求:

curl -i -X POST --url http://ff-nginxdev-01:8000/fund-information-services/first-information/fund/630 --header 'Host: your_api' 

それは動作します

関連する問題