問題描述
研發同事反映,部分瀏覽器訪問jenkins會返回 "400 Bad Request: The plain HTTP request was sent to HTTPS port
"
url由https://a.example.com/jenkins跳轉成http://a.example.com:443/jenkins,主要在登錄和註銷時出現錯誤
原因
由於前端代理爲https,但jenkins頁面中加載的衆多js中多爲動態加載,如果後端是http,動態加載的js就會走http,導致js報錯從而導致一些功能不能用,這樣瀏覽器就會產生400錯誤
解決方法
在nginx.conf中jenkins對應的location中增加proxy_set_header X-Forwarded-Proto $scheme;,正確識別實際用戶發出的協議是http還是https