nginx nodejs 502 upstream prematurely closed connection while reading response header from upstream
問題描述:
在nginx + nodejs的應用場景中,請求URL中如果含有不能進行編碼的非法字元則nodejs http server會直接socket hang up斷開連線,導致nginx報錯"upstream prematurely closed connection while reading response header from upstream", nginx對客戶端返回502錯誤。
測試了Nodejs的兩個版本v4.5.0和v8.11.4,都是這種處理方式,且不輸出錯誤日誌。作為參照java的tomcat對於這種情況的處理是:返回400錯誤,同時記錄一條錯誤日誌。
示例URL:
如果請求是由前端javascrip指令碼發起,則時常會有非法字元出現,如讀取客戶端mac
http://test.pengpengzhou.com/data?mac=CF-頛摾$▒?&uid=1536675808a106e
解決方案:
在nginx.conf裡增加過濾條件,對含有非法字元的請求直接返回400錯誤,不再轉發。
if ( $request_uri ~ [^A-Za-z0-9:\.\/\[email protected]&=\$%,#\+\-_!~\;'\[\]\{\}\^] ) {
return 400;
}
相關推薦
nginx nodejs 502 upstream prematurely closed connection while reading response header from upstream
問題描述: 在nginx + nodejs的應用場景中,請求URL中如果含有不能進行編碼的非法字元則nodejs http server會直接socket hang up斷開連線,導致nginx報錯"upstream prematurely closed connectio
graphite報錯:upstream prematurely closed connection while reading response header from upstream
線上監控系統使用grafana+graphite,graphite使用nginx+uwsgi啟動。有一次在grafana上監控圖出現錯誤,顯示響應式502,於是先檢查graphite-web,發現在graphite-web介面上偶爾打不開。 然後再nginx的error日誌上顯示如下資訊:
Nginx Upstream prematurely closed connection while reading upstream...
今天發現除了火狐,其他瀏覽器在開啟後臺ckfinder都會出現 net::ERR_INCOMPLETE_CHUNKED_ENCODING 錯誤,但是本地除錯沒有這個錯誤,最終發現是伺服器的Nginx 配置上有問題,檢視error.log 顯示的是Upstream prema
nginx 超時問題: upstream timed out (110: Connection timed out) while reading response header from upstream
目錄 錯誤內容 錯誤原因 錯誤解決辦法 錯誤內容 我們可以在error.log 裡面可以看到 錯誤內容:upstream timed out (110: Connection timed out) while reading response header from upstream
Nginx 錯誤502 upstream sent too big header while reading response header from upstream
Nginx 502 Bad Gateway的含義是請求的PHP-CGI已經執行,但是由於某種原因(一般是讀取資源的問題)沒有執行完畢而導致PHP-CGI程序終止。 Nginx 504 Gateway Time-out的含義是所請求的閘道器沒有請求到,簡單來說就是沒有請求到可
修復Nginx 502錯誤:upstream sent too big header while reading response header from upstream
最近發現Nginx+Laravel 搭建的網站搜尋某些關鍵字時返回502錯誤。 查了一下Nginx的錯誤日誌,發現如下錯誤 2015/03/19 10:46:40 [error] 6412#0: *16436265 upstream sent too big header
failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x
failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x,
解決 recv() failed (104: Connection reset by peer) while reading response header from upstream
Nginx出現502 Bad Gateway 錯誤, 查了Nginx的錯誤日誌為: 2014/08/02 16:14:31 [error] 17029#0: *17941 recv() failed (104: Connection reset by peer) whil
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream 問題解決
配置好了 nginx.conf 和 php7.0-fpm.conf 檔案,但是要訪問 php 檔案的時候,卻不顯示任何內容或者顯示“File not found”,問題在於要訪問的 php 檔案 php7.0-fpm 沒有訪問許可權,修改下訪問許可權即可。 改成如下圖所示: 附
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream 問題解決
配置好了 nginx.conf 和 php7.0-fpm.conf 檔案,但是要訪問 php 檔案的時候,卻不顯示任何內容或者顯示“File not found”,問題在於要訪問的 php 檔案 php7.0-fpm 沒有訪問許可權,修改下訪問許可權即可。 改成如下圖所
記錄一次 docker:Primary script unknown" while reading response header from upstream
這個問題簡單翻譯過來就是: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 這行配置無法幫我找到 傳過來的檔案。試了一下寫一個 index.html 檔案進行測試,發現是有的。
upstream sent invalid header while reading response header from upstream 錯誤解決
由於最近線上出現502錯誤比較蛋疼,所以重新把nginx詳細配置做下說明,以此來查詢問題。 nginx 配置 location / { proxy_next_upstream http_500 http_502 http_504 error tim
nginx 499 日誌記錄client closed connection while waiti
close posit nginx檢測 gin 服務端 連接 sel ont 揮手 error.log 中出現大量以下日誌(info級別才會記錄如下日誌):2013/11/13 11:26:10 [info] 18382#0: *2799 client closed con
nginx: upstream timed out (110: Connection timed out) while reading response header
server{}配置中新增以下配置即可: large_client_header_buffers 4 16k; #header大小 client_max_body_size 300m; #上傳檔案大小限制  
nginx [error] 15644#0: *112680 recv() failed (104: Connection reset by peer) while reading response
參考地址 https://serverfault.com/questions/543999/nginx-errors-recv-failed-104-connection-reset-by-peer-while-reading-respon/544106 網站登入的時候
nginx 報錯 connect() failed (111: Connection refused) while connecting to upstream
連接不上 安裝 tst 端口 修改 rip 網站頁面 導致 file 公司網站搬遷到新服務器後,發現站點訪問不了,network裏面提示502,查看相關的server配置,感覺沒有什麽問題,經過測試發現txt、html、等非php文件能夠直接訪問,也就是php訪問不了,初步
myBatis連接MySQL報異常:No operations allowed after connection closed.Connection was implicitly closed
csdn spa logs action env target details 默認 col 網站運行一個晚上,早上來上班,發現報錯: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.M
nginx的502問題
nginx的502問題1.配置錯誤因為nginx找不到php-fpm了或者socket文件權限不對,所以報錯,一般是nginx的配置文件中fastcgi_pass後面的路徑配置不當,後面可以是socket或者是ip:port,從php5.4版本之後如果使用socket方式,默認權限給的比較低,所以需要把監聽權
Nginx 顯示502 Bad Gateway錯誤
二維碼 div 名稱 ear 配置 star 成功 art edi 今天系統發布到測試環境,有一個用戶登錄後顯示502 Bad Gateway錯誤,其他的用戶都登錄成功。但是在開發機鏈接測試數據庫,使用該賬號登錄成功。 初步猜測是Nginx的問題,查看nginx的錯誤
FTPClient TLS 與 FTP 進行數據傳輸異常:Remote host closed connection during handshake
except cti 定義 sed pbs 8.0 java.net src same 環境:java JDK 1.8、org.apache.commons-net-3.6.jar、端口已放開 FTPClient ftpClient = new FTPClient(prot