mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5658] [Bug]: 3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1 #3940
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3940
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hqylwrx on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5658
Describe the bug
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
客户端----nginx https反代170001----docker网关:172.19.0.1----172.19.0.x: xxx端口
我3xui是docker版本,3xui版本是 v3.4.1, 不停出现这个,不知道是什么原因造成
services:
3xui:
image: ghcr.io/mhsanaei/3x-ui:latest
container_name: 3xui_app
cap_add:
- NET_ADMIN
- NET_RAW
volumes:
- $PWD/db/:/etc/x-ui/
- $PWD/cert/:/root/cert/
- /www/server/panel/vhost/cert/www.test.com/:/root/cert-pem/
environment:
XRAY_VMESS_AEAD_FORCED: "false"
XUI_ENABLE_FAIL2BAN: "true"
# XUI_INIT_WEB_BASE_PATH: "/"
# XUI_DB_TYPE: "postgres"
# XUI_DB_DSN: "postgres://xui:xui@postgres:5432/xui?sslmode=disable"
tty: true
ports:
- "2053:2053"
- "17002-17020:17002-17020"
restart: unless-stopped
postgres:
image: postgres:16-alpine
container_name: 3xui_postgres
profiles: ["postgres"]
environment:
POSTGRES_USER: xui
POSTGRES_PASSWORD: xui
POSTGRES_DB: xui
volumes:
- $PWD/pgdata/:/var/lib/postgresql/data
restart: unless-stopped
nginx
proxy_cache_path /www/wwwroot/www.test.com_17000/proxy_cache_dir levels=1:2 keys_zone=www.test.com_17000_cache:20m inactive=1d max_size=5g;
=====================================
HTTP 17000 -> HTTPS 17001
=====================================
server {
listen 17000;
server_name www.test.com;
}
=====================================
HTTPS 17001
=====================================
server {
listen 17001 ssl;
listen 17001 quic reuseport;
listen [::]:17001 quic reuseport;
http3 on;
location / {
}
}
How to reproduce the problem
编排日志
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
3xui_app | WARNING - Unauthorized WebSocket connection attempt from 172.19.0.1
Expected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.3.1
Xray-core version
25
How did you install 3x-ui?
Docker / Docker Compose
Operating system
Centos
Which parts of the panel are affected?
No response
Browser (only if it is a UI bug)
Chrome
Is the panel behind a reverse proxy or CDN?
Yes — Nginx
Before submitting
@github-actions[bot] commented on GitHub (Jun 29, 2026):
这是面板正常拒绝未认证 WebSocket 升级请求时记录的警告,并非安全漏洞,也不代表面板存在缺陷。下面解释原因及处理方式。
为什么会出现这条日志
日志来源是
internal/web/controller/websocket.go第 67 行:当 WebSocket 升级请求抵达面板时,若没有有效的登录会话 cookie,面板会返回 HTTP 401 并记录此警告。为什么 IP 始终是
172.19.0.1172.19.0.1是 Docker bridge 网关地址,即宿主机在容器内部网络中的 IP。Nginx 运行在宿主机,通过该地址将请求转发到容器。面板默认只信任回环地址(127.0.0.1/32,::1/128)作为可信代理(见internal/web/service/setting.go第 56 行),因此即使 Nginx 传递了X-Real-IP头,面板也会忽略它,日志中始终显示172.19.0.1而不是真实客户端 IP。为什么会"不停出现"
前端 WebSocket 客户端(
frontend/src/api/websocket.ts)实现了自动重连逻辑:连接被服务端关闭后,客户端会按指数退避(最长 30 秒)持续重连,超过 10 次失败后每 60 秒重试一次,且没有终止条件。由于浏览器 WebSocket API 在握手阶段拿不到 HTTP 状态码,客户端无法区分 401 和网络故障,因此每次都会重试,每次都会触发该警告。常见触发场景:
172.19.0.1:2053(从日志中monitorsyslog tag 可判断)排查步骤
检查是否有浏览器标签页停留在面板页面(未登录或会话过期)。若有,重新登录后警告应停止或减少。
若怀疑是宝塔监控探测所致,暂时在宝塔中禁用对该站点的后端存活检测,观察日志是否消失。
若需要在日志中看到真实客户端 IP(便于定位来源),在面板 Settings → General → Trusted proxy CIDRs 中添加 Docker bridge 网段:
保存后,日志中将显示真实 IP,有助于判断请求来源。
若重置会话后问题仍持续,请确认 Nginx 侧的 cookie 传递是否正常——
proxy_pass使用 HTTPS 时需确保proxy_ssl_verify off已生效,且面板 session cookie 的Secure和SameSite属性与代理端口匹配。结论
这条警告本身说明面板的访问控制在正常工作。若日志量影响排查,优先检查浏览器标签页和宝塔监控配置。
此回复由自动化工具生成,维护者可能会进一步跟进。
@hqylwrx commented on GitHub (Jun 29, 2026):
还是AI靠谱。。。
@Kvinam commented on GitHub (Jul 4, 2026):
你的nginx反代xui面板的时候使用子路径吗
@hqylwrx commented on GitHub (Jul 15, 2026):
没有,默认就OK