📝 添加 Terminal 一直黑屏解决方案

This commit is contained in:
naiba 2021-08-19 09:22:48 +08:00
parent 7990689949
commit 800dd07713
4 changed files with 15 additions and 13 deletions

View File

@ -4,7 +4,7 @@
<br>
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
<br><br>
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.9.23&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.6.7-brightgreen?style=for-the-badge&logo=linux">
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.9.25&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.6.7-brightgreen?style=for-the-badge&logo=linux">
<br>
<br>
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
@ -270,14 +270,7 @@ restart() {
</details>
<details>
<summary>提示实时通道断开?</summary>
### 启用 HTTPS
使用宝塔反代或者上 CDN建议 Agent 配置 跟 访问管理面板 使用不同的域名,这样管理面板使用的域名可以直接套 CDNAgent 配置的域名是解析管理面板 IP 使用的,也方便后面管理面板迁移(如果你使用 IP后面 IP 更换了,需要修改每个 agent就麻烦了
### 实时通道断开(WebSocket 反代)
<summary>实时通道断开/Terminal管理一直黑屏</summary>
使用反向代理时需要针对 `/ws` 路径的 WebSocket 进行特别配置以支持实时更新服务器状态。
- Nginx(宝塔):在你的 nginx 配置文件中加入以下代码
@ -288,7 +281,7 @@ restart() {
#原有的一些配置
#server_name blablabla...
location /ws {
location ~ ^/(ws|terminal/.+)$ {
proxy_pass http://ip:站点访问端口;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;

View File

@ -370,6 +370,7 @@ func (cp *commonPage) createTerminal(c *gin.Context) {
}
c.HTML(http.StatusOK, "dashboard/terminal", mygin.CommonEnvironment(c, gin.H{
"SessionID": id,
"SessionID": id,
"ServerName": server.Name,
}))
}

View File

@ -6,7 +6,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tty#{{.SessionID}} - {{.Title}}</title>
<title>tty@{{.ServerName}} - {{.Title}}</title>
<link rel="shortcut icon" type="image/png" href="/static/logo.svg?v20210804" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@4.13.0/css/xterm.css">
</head>
@ -20,6 +20,10 @@
width: 100vw;
height: 100vh;
}
body {
background-color: black;
}
</style>
<body onresize="onResize()">
@ -44,6 +48,10 @@
onResize()
}
socket.onerror = () => {
alert('Terminal 连接失败,请检查 /terminal/* 的 WebSocket 反代情况')
}
function onResize() {
fitAddon.fit()
const w = fitAddon.proposeDimensions();

View File

@ -13,7 +13,7 @@ import (
pb "github.com/naiba/nezha/proto"
)
var Version = "v0.9.23" // !!记得修改 README 中的 badge 版本!!
var Version = "v0.9.25" // !!记得修改 README 中的 badge 版本!!
var (
Conf *model.Config