1xx 信息响应
101 Switching Protocols
服务端同意按客户端 Upgrade 请求头的要求切换协议。
最常见于建立 WebSocket 连接:HTTP 请求被“升级”,之后这条连接改用 WebSocket 协议通信。
使用说明
- 如果 nginx 后面的 WebSocket 握手失败,检查是否配置了
proxy_set_header Upgrade $http_upgrade;、Connection "upgrade"以及proxy_http_version 1.1。
响应示例
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Date: Thu, 22 Oct 2026 08:00:00 GMT 用 curl -I https://example.com 可以查看某个地址返回的状态码和响应头。