使用了Nginx的反向代理配置以下:html
upstream test{ keepalive 1; server 192.168.1.63:4000; } server { listen 4000; server_name localhost; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_buffering off; proxy_pass http://test; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
沒法與後端服務保持長鏈接,即時後端服務顯示返回Connection:keep-alive給nginx。nginx
抓包發現:nginx默認使用了http1.0協議向後端轉發請求,頭中顯示指定了Connection: close ,修改配置以下:segmentfault
proxy_http_version 1.1; proxy_set_header Connection "";
長鏈接生效。後端
PS:新版的wireshark 「不能」失敗HTTP1.0代理