[点晴永久免费OA]网站通过Nginx反向代理访问,现在不定时出现:错误 - 101 详情原因:ERR_CONNECTION_RESET 搜索
|
admin
2026年7月3日 17:51
本文热度 212
|
:网站通过Nginx反向代理访问,现在不定时出现:错误 - 101 详情原因:ERR_CONNECTION_RESET 搜索

错误 - 101 ERR_CONNECTION_RESET 完整解决方案
一、先看懂你的故障特征(定位核心诱因)
登录成功、WebSocket 消息推送正常 → 长连接链路没问题
页面主体 HTTP 请求直接报连接重置、不定时复现
外网访问才出现,内网大概率正常
典型根因:普通 HTTP 页面请求被 Nginx / 防火墙 / 中间设备提前掐断 TCP 连接,WebSocket 长连接因持续心跳躲过超时,所以消息能收到、页面打不开。
二、Nginx 配置修复(90% 场景直接解决,分两步)
1. 全局 proxy 缓冲区、超时参数(http 块)
打开 nginx.conf http {} 段添加:
http {
proxy_buffer_size 128k;
proxy_buffers 8 256k;
proxy_busy_buffers_size 512k;
proxy_max_temp_file_size 0;
proxy_connect_timeout 10s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
client_header_timeout 60s;
client_body_timeout 60s;
send_timeout 120s;
keepalive_timeout 120s;
keepalive_requests 1000;
upstream backend_server {
server 127.0.0.1:8080;
keepalive 64;
}}
2. 站点 location 标准反向代理模板(关键修复项)
server {
listen 443 ssl;
server_name xxx.com;
ssl_certificate cert/xxx.pem;
ssl_certificate_key cert/xxx.key;
location / {
proxy_pass http://backend_server;
proxy_http_version 1.1;
proxy_set_header Connection "";
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_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
}
location /ws/ {
proxy_pass http://backend_server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}}map $http_upgrade $connection_upgrade {
default upgrade;
'' close;}
3. 配置生效验证
nginx -t systemctl reload nginx
三、第二层排查:中间网络设备(外网专属诱因)
1. 云厂商安全组 / 防火墙 / 负载均衡
2. 运营商 / 用户端防火墙、企业代理 DPI
3. MTU 分片导致 TCP 断连
HTTPS 大包页面分片失败直接 RST,添加配置:
server {
listen 443 ssl;
ssl_mtu 1400;}
四、第三层:后端应用侧问题
1、后端线程池耗尽、请求阻塞
2、后端主动关闭连接
后端返回 Connection: close 头、会话过期强制断开 TCP,可 Nginx 强制覆盖:
proxy_set_header Connection "";proxy_pass_header Connection;
3、会话 Cookie 跨代理丢失导致页面循环刷新断连
检查 X-Forwarded-Proto、Cookie Secure 配置,HTTPS 站点 Cookie 必须带 Secure。
五、日志定位(快速确认谁发的 RST)
1、Nginx 错误日志查看连接重置来源
tail -f /var/log/nginx/error.log
2、抓包确认 RST 发送方
tcpdump -i eth0 'tcp[tcpflags] & tcp-rst != 0' -nn
RST 源 IP 是 Nginx 本机 → Nginx 超时 / 缓冲区配置问题
RST 源 IP 是网关 / 运营商 IP → 网络中间设备拦截
六、前端临时规避方案(SPA / 管理系统)
页面接口添加超时重试逻辑,捕获 net::ERR_CONNECTION_RESET 自动刷新;
WebSocket 维持 30s 一次心跳,避免整条 TCP 链路被防火墙清理;
静态资源(js/css/img)拆分 CDN,减少首页大包加载超时。
七、最简排查顺序(按优先级执行)
复制上方完整 Nginx proxy 超时 + buffer 配置重载,测试;
切换手机热点访问,区分是服务器配置还是宽带防火墙;
查看 Nginx error.log 确认重置来源;
云后台调整负载均衡 / NAT 空闲超时;
检查后端应用内存、线程、错误日志。
该文章在 2026/7/3 17:54:32 编辑过