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,回頭跟進一下,待續字體

相關文章
相關標籤/搜索