Nginx系列5之讓Nginx支援HTTP1 1

2021-09-07 07:54:59 字數 443 閱讀 9692

nginx在反向**http協議的時候,預設使用的是http1.0去向後端伺服器獲取響應的內容後在返回給客戶端。

http1.0和http1.1的乙個不同之處就是,http1.0不支援http keep-alive。nginx在後端伺服器請求時使用了http1.0同時使用http header的connection:close通知後端伺服器主動關閉連線。這樣會導致任何乙個客戶端的請求都在後端伺服器上產生了乙個time-wait狀態的連線。所以我們需要在nginx上啟用http1.1的向後端傳送請求,同時支援keep-alive。

配置http1.1

http

server

'''}

'''}

我們增加三個引數keepalive 50,proxy_http_version 1.1 , proxy_set_header connection 來配置。

Nginx系列(八 nginx日誌)

remote addr,http x forwarded for 記錄客戶端ip位址 remote user 記錄客戶端使用者名稱 request 記錄請求的url和http協議 status 記錄請求狀態 body bytes sent 傳送給客戶端的位元組數,不包括響應頭的大小 該變數與apac...

Nginx系列之1 限流

安裝準備 cd usr local src wget 解壓 tar zxvf usr local src nginx 1.18.0.tar.gz 進入到 nginx 1.18.0 目錄下 cd nginx 1.18.0 生成 makefile configure 編譯並且安裝 預設輸出到 usr l...

Nginx系列(十三 nginx負載均衡)

負載均衡 upstream webserver 反向 server web伺服器 server location php 1.輪詢 預設 upstream webserver2.weight upstream webserver3.ip hash 解決session共享問題 upstream web...