我已在Amazon API Gateway中为API网关配置了一组资源。所有资源都是三个站点的代理资源。决定使用API网关,以便API Key可以统一,域也可以统一。
通过控制台进行的测试是成功的,响应是在一秒内完成的。由于我在那里启用了详细的日志,因此可以从Cloudwatch跟踪日志。
使用curl通过提供的url尝试相同,最终响应是荒谬的,而我运行nginx的http端点几乎立即添加到访问日志,相应的Cloudwatch日志也显示正确的执行。
Cloudwatch日志
08:36:20 Usage Plan check succeeded for API Key **********************************fpqlo7 and API Stage bzfet1144f/v3
08:36:20 Starting execution for request: 29b3d251-9fe0-11e6-8dd6-93361a1890a5
08:36:20 HTTP Method: GET, Resource Path: /app/coupon/p/12356
08:36:20 API Key: **********************************fpqlo7
08:36:20 Method request path: {proxy=coupon/p/12356}
08:36:20 Method request query string: {}
08:36:20 Method request headers: {Accept=*/*, CloudFront-Viewer-Country=IN, CloudFront-Forwarded-Proto=https, CloudFront-Is-Tablet-Viewer=false, CloudFront-Is-Mobile-Viewer=false, User-Agent=Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36, X-Forwarded-Proto=https, CloudFront-Is-SmartTV-Viewer=false, Host=bzfet1144f.execute-api.eu-west-1.amazonaws.com, X
08:36:20 Method request body before transformations: null
08:36:20 Endpoint request URI: http://*****************/app/coupon/p/12356
08:36:20 Endpoint request headers: {x-amzn-apigateway-api-id=bzfet1144f, Accept=*/*, CloudFront-Viewer-Country=IN, CloudFront-Forwarded-Proto=https, CloudFront-Is-Tablet-Viewer=false, User-Agent=Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36, CloudFront-Is-Mobile-Viewer=false, X-Forwarded-Proto=https, CloudFront-Is-SmartTV-Viewer=false, Host=bzfet1144f
08:36:20 Endpoint request body after transformations: null
08:36:20 Endpoint response body before transformations: [["\/app\/coupon\/p\/12356","coupon\/p\/12356"]]
08:36:20 Endpoint response headers: {Transfer-Encoding=chunked, Server=nginx/1.4.6 (Ubuntu), Cache-Control=no-cache, must-revalidate, Connection=keep-alive, Vary=Accept-Encoding, Date=Tue, 01 Nov 2016 03:06:35 GMT, Content-Type=application/json}
08:36:20 Method response body after transformations: [["\/app\/coupon\/p\/12356","coupon\/p\/12356"]]
08:36:20 Method response headers: {Transfer-Encoding=chunked, Server=nginx/1.4.6 (Ubuntu), Cache-Control=no-cache, must-revalidate, Connection=keep-alive, Vary=Accept-Encoding, Date=Tue, 01 Nov 2016 03:06:35 GMT, Content-Type=application/json}
08:36:20 Successfully completed execution
08:36:20 Method completed with status: 200
卷曲命令输出
< HTTP/1.1 504 Gateway Time-out
< Content-Type: text/html
< Content-Length: 669
< Connection: keep-alive
* Server CloudFront is not blacklisted
< Server: CloudFront
< Date: Tue, 01 Nov 2016 03:06:50 GMT
< X-Cache: Error from cloudfront
< Via: 1.1 d11c243977c97aea69643cb52490b7e9.cloudfront.net (CloudFront)
< X-Amz-Cf-Id: tVsfEoAXfG9KuEVgw9S9YP98z4DPayqeCdvlIbCPayjRHaS5QvUOuQ==
上面是带有错误消息的标准html页面,因为 CloudFront试图与原点建立连接,但尝试失败或原点关闭连接。
关于这是否是cloudfront和eu-west-1地区的问题,或者在配置系统时我错过了什么,我很沮丧。
答案 0 :(得分:1)
我在API网关配置方面遇到了同样的问题。这是标题&#39; Transfer-Encoding = chunked&#39;的已知CloudFront问题。由于无法更改针对http_proxy集成的集成响应,因此AWS Support的解决方案是阻止后端服务器发送此类标头。据我所知,这个天堂尚未得到解决..
此致 卡斯