nginx使用中碰到的问题

作amp服务时,各类请求经过nginx打到resin服务器上,有个接口是抓取woff字体java

woff tff字体获取后,提示以下错误,nginx

Failed to decode downloaded font
好比Failed to decode downloaded font:  http://amp.sogoucdn.com/amp/r/twocents.lifehacker.com//f.kinja-static.com/a…ets/fonts/elizabeth-serif/elizabethserif-lightitalic-webfont.woff?09162015
amp:1 OTS parsing error: file less than 4 bytes
 
由于要用到byte[] 因此全部的编码都走的iso-8859-1,参见 http://www.tuicool.com/articles/I7Z3If
首先对本身接口获取的内容与原来接口获取的内容进行比对,发现没有不一样
而后,经过debug发现,单独访问该接口能够进入requestmapping,而同一个页面中会请求屡次该接口,则不会进入requestmapping接口
加入nginx日志log_format,以下

log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for '
'"$upstream_addr" "$upstream_status" "$upstream_response_time" "$request_time"';web

打印出来的内容证实,同时发起的屡次请求,只有几毫秒的upstream_response_time,而单独访问时则200+毫秒spring

一开始觉得是并发问题,可是量不大,并且用到了epoll服务器

因此,直接查看web.xml中的fiter,对CharacterEncodingFilter进行debug,抓取到以下异常并发

org.springframework.web.util.NestedServletException: Request processing failed;
nested exception is java.lang.IllegalStateException: Could not get HttpServletRequest URI: Illegal character in hostname at index 10: http: //amp_server:80/reventondc/amp/r/f.kinja-static.com/assets/fonts/elizabeth-serif/elizabethserif-bold-webfont.woff2?09162015app

发现是下划线的问题,由于是测试环境,没有用$host,直接传过来了upstream的名称,由于带有下划线,因此报错less

后面改为用host,问题解决测试

可是屡次请求有问题,单次请求就能够,初步判断是spring的小bug,回头跟进一下,待续字体

相关文章
相关标签/搜索