nginx使用中碰到的问题
做amp服务时,各种请求通过nginx打到resin服务器上,有个接口是抓取woff字体
woff tff字体获取后,提示如下错误,
比如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
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"';
打印出来的内容证明,同时发起的多次请求,只有几毫秒的upstream_response_time,而单独访问时则200+毫秒
一开始以为是并发问题,但是量不大,而且用到了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?09162015
发现是下划线的问题,因为是测试环境,没有用$host,直接传过来了upstream的名称,因为带有下划线,所以报错
后面改成用host,问题解决
但是多次请求有问题,单次请求就可以,初步判断是spring的小bug,回头跟进一下,待续