11.3.4.3. API 게이트웨이가 3scale를 올바르게 호출합니까?


문제 해결을 위해 API 게이트웨이가 3scale에 수행하는 요청을 확인하려면 nginx.conf의 3scale authrep 위치(API Key 및 App\_id 인증 모드의 경우/threescale_authrep )에만 다음 스니펫을 추가할 수 있습니다.

body_filter_by_lua_block{
  if ngx.req.get_headers()["X-3scale-debug"] == ngx.var.provider_key then
    local resp = ""
    ngx.ctx.buffered = (ngx.ctx.buffered or "") .. string.sub(ngx.arg[1], 1, 1000)
    if ngx.arg[2] then
      resp = ngx.ctx.buffered
    end

    ngx.log(0, ngx.req.raw_header())
    ngx.log(0, resp)
  end
}

이 코드 조각은 X-3scale-debug 헤더 가 전송되면 nginx error.log에 다음과 같은 추가 로깅을 추가합니다(예: curl -v -H 'X-3scale-debug): YOUR_PROVIDER_KEY' -X GET "https://726e3b99.ngrok.com/api/contacts.json?access_token=7c6f24f5"

이렇게 하면 다음 로그 항목이 생성됩니다.

2016/05/05 14:24:33 [] 7238#0: *57 [lua] body_filter_by_lua:7: GET /api/contacts.json?access_token=7c6f24f5 HTTP/1.1
Host: 726e3b99.ngrok.io
User-Agent: curl/7.43.0
Accept: */*
X-Forwarded-Proto: https
X-Forwarded-For: 2.139.235.79

 while sending to client, client: 127.0.0.1, server: pili-virtualbox, request: "GET /api/contacts.json?access_token=7c6f24f5 HTTP/1.1", subrequest: "/threescale_authrep", upstream: "https://54.83.62.94:443/transactions/oauth_authrep.xml?provider_key=REDACTED&service_id=REDACTED&usage[hits]=1&access_token=7c6f24f5", host: "726e3b99.ngrok.io"
2016/05/05 14:24:33 [] 7238#0: *57 [lua] body_filter_by_lua:8: <?xml version="1.0" encoding="UTF-8"?><error code="access_token_invalid">access_token "7c6f24f5" is invalid: expired or never defined</error> while sending to client, client: 127.0.0.1, server: pili-virtualbox, request: "GET /api/contacts.json?access_token=7c6f24f5 HTTP/1.1", subrequest: "/threescale_authrep", upstream: "https://54.83.62.94:443/transactions/oauth_authrep.xml?provider_key=REDACTED&service_id=REDACTED&usage[hits]=1&access_token=7c6f24f5", host: "726e3b99.ngrok.io"

첫 번째 항목(2016/05 14:24:33 [] 7238#0: *57 [lua] body_filter_by_lua:7:)은 3scale로 전송된 요청 헤더를 출력합니다. Host, User-Agent, accept, X-Forwarded-Proto 및 X-Forwarded-Forwarded.

두 번째 항목(2016/05/05 14:24:33 [] 7238#0: *57 [lua] body_filter_by_lua:8:)은 3scale의 응답을 출력합니다. 이 경우 <error code="access_token_invalid">access_token "7c6f24f is invalid: expired or never defined</error> 입니다.

둘 다 원래 요청 (GET /api/Contacts.json?access_token=7c6f5) 및 하위 요청 위치 (/threescale_authrep) 및 업스트림 요청 ( upstream: "hits=1&access_token=7c6f5".)을 출력합니다.) 이 마지막 값을 사용하면 3scale IP 중 어떤 것이 해결되었는지와 3scale의 정확한 요청도 확인할 수 있습니다.

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동