我在apgateway控制台中创建了一个API,它用作运行java应用程序的后端服务器的http代理。我们部署了api,创建了一个通过cloudfront托管的自定义域。现在,当我在我的web应用程序中使用新的cloundfront URL时,某些API不会立即返回。相同的行为甚至可以卷曲命令aws apigateway的不一致响应
curl -v -H "Cookie:session_token=llzAwur3FZS78po6b21FEgvXzDUFY3" https://xyz.execute-api.us-east-1.amazonaws.com/test/api/folder/roo
同一API端点将具有不同的响应时间被注意到(有时是大约1秒,有时也可以是几秒钟)。有时它也会超时。后端服务器(jetty)请求日志显示响应是即时发送的。我们如何调查我们的API网关部署出了什么问题?
例如,我有来自网关的这两个响应。坏一个
< HTTP/1.1 504 Gateway Time-out
< Content-Type: text/html
< Content-Length: 669
< Connection: keep-alive
< Server: CloudFront
< Date: Fri, 11 Nov 2016 12:27:14 GMT
< X-Cache: Error from cloudfront
< Via: 1.1 xyz.cloudfront.net (CloudFront)
< X-Amz-Cf-Id: Wfjk3bqdwhAbFQhzerMd0DJ5t_2xAF6E_NUTvqif1p9cb9E-jy0GUw==
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: 881Muk_9up7A0phYvmmchNkYWj16yFCsthuKFivS2vbtpULtCk9lnw==
</PRE>
<ADDRESS>
</ADDRESS>
* Connection #0 to host ulj2mxzix6.execute-api.us-east-1.amazonaws.com left intact
</BODY></HTML>
而且this--好一个
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Content-Length: 1839
< Connection: keep-alive
< Date: Fri, 11 Nov 2016 12:28:43 GMT
< x-amzn-Remapped-Connection: keep-alive
< x-amzn-Remapped-Content-Length: 1839
< x-amzn-Remapped-Date: Fri, 11 Nov 2016 12:28:43 GMT
< x-amzn-Remapped-Server: nginx/1.4.6 (Ubuntu)
< x-amzn-RequestId: 621bff67-a80a-11e6-bb0a-1bc973821ef5
< X-Cache: Miss from cloudfront
< Via: 1.1 1d43f56d3213a63608863fd0e49585b9.cloudfront.net (CloudFront)
< X-Amz-Cf-Id: ZGwu2NAXKCouMssDjHwSnjyWXe4OFukmeyL7nzC_Y4Lz6QnixdhbEg==
编辑/分辨率:
正如答复中提到下面我不得不禁用头获得的内容长度响应标题。我使用Spring MVC中的REST API实现,并添加以下过滤器似乎已经完成了招
<filter>
<filter-name>bufferFilter</filter-name>
<filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>bufferFilter</filter-name>
<url-pattern>/api/*</url-pattern>
</filter-mapping>
您是否在API网关前放置了CloudFront分配? –
是的。我创建了一个具有SSL证书的自定义域。正如我所提到的,curl命令有时会起作用,但它大部分会挂起或需要一分钟左右才能返回。任何帮助解决我的问题,将不胜感激。谢谢 –
您是否创建了自定义域并指向您自己的CloudFront分配,然后指向API网关? –