2016-11-25 6 views
0

REST 및 API 게이트웨이에 새로 추가되었습니다.Kong에 API 추가

저는 Cassandra를 사용하여 개발 컴퓨터에 Kong을 설치했으며 API (스프링 부팅 응용 프로그램)를 추가하려고했지만 문서를 읽으면 작동하도록 고심하고 있습니다.

내 API : 나는

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 
        }, 
    ...... 
    ...... 

모두를 실행할 때

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

잘보고 내가 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'을 해결할 수 없을 것입니다.그것을 해결할 수있는 리졸버 (Kong의 설정 파일을 통해 그렇게 할 수있는)를 사용하고 이상적으로는 FQDN을 사용하도록 Nginx를 적절히 구성해야합니다. – thibaultcha

답변

0

기본적으로 동적 SSL 플러그인은 특정 SSL 인증서를 API의 request_host에 바인딩합니다. API에 request_path을 정의하기 만하면 request_path을 사용할 때 SSL 플러그인이 적용되지 않음을 의미합니다.

당신은 그에서처럼 그것이 이유를 이해하기 위해 더 많은 읽을 수 있습니다 여기에

Proxy Reference 내 솔루션입니다 : this issue

귀하의 요청 작업을하려면, 내가있는 API가 어떻게 프록시 당신에 대해 읽어해야한다고 생각

방법 1 : 문제에 대한 변경 "strip_request_path"사실

"strip_request_path": true 

이 방법에 요를 가정 대신

"request_host" : "your_api" 

그런 다음 귀하의 요청 헤더에,이 request_host 추가해야 request_host 사용 : u는 첫째

방법 2 request_host 지정하지 않은

예 요청 :

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

작동합니다.