公网反代默认转发 WebSocket 升级头
CI / verify (push) Canceled after 0s

This commit is contained in:
2026-10-17 10:21:24 +08:00
parent 302248a907
commit c1bcdd0b86
3 changed files with 11 additions and 3 deletions
+1
View File
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
- **终端体验**:多标签会话、断线一键重连、复制粘贴(Ctrl/⌘+Shift+C/V)、字号记忆、清屏,以及输出里的 URL 可直接点击;终端高度可拖动(默认跟随视口,双击恢复自适应),鼠标向下滚动能把最后一行推到视口顶部 - **终端体验**:多标签会话、断线一键重连、复制粘贴(Ctrl/⌘+Shift+C/V)、字号记忆、清屏,以及输出里的 URL 可直接点击;终端高度可拖动(默认跟随视口,双击恢复自适应),鼠标向下滚动能把最后一行推到视口顶部
- **移动端只读**:窄屏默认只读(可滚动、可复制),需要输入时显式点「允许输入」,减少手机上的误触 - **移动端只读**:窄屏默认只读(可滚动、可复制),需要输入时显式点「允许输入」,减少手机上的误触
- **终端开关按布尔语义解析**:`1` / `true` / `on` 都视为开启,避免开关显示已打开、接口却按未启用拒绝 - **终端开关按布尔语义解析**:`1` / `true` / `on` 都视为开启,避免开关显示已打开、接口却按未启用拒绝
- **公网反代默认转发 WebSocket 升级头**:新建穿透规则的公网反代部署选项默认打开「WebSocket 支持」,老规则缺少该键时也按开启处理(显式关掉的保持关闭)。此前该开关默认关闭,NAS 桌面、各类控制台、Portainer、Home Assistant 等依赖 WebSocket 的页面在公网访问时会一直挂起
### 测试 ### 测试
+4 -1
View File
@@ -831,7 +831,10 @@ const editingProxy = ref<FrpProxy | null>(null)
const downloadPolling = ref(false) const downloadPolling = ref(false)
function defaultProxyOptions(): FrpProxyOptions & { allow_ips_text?: string } { function defaultProxyOptions(): FrpProxyOptions & { allow_ips_text?: string } {
return { transport: {}, health_check: {}, load_balancer: {}, nat_traversal: { disable_assisted_addrs: false }, allow_ips_text: '' } // websocket 默认开启:公网反代模板只有打开它才会转发 Upgrade/Connection 头,
// 关掉后 NAS 桌面、控制台、Portainer 这类页面的 WebSocket 会一直挂起。
// 需要关掉的规则可在「公网反代 → 部署设置」里单独改。
return { websocket: true, transport: {}, health_check: {}, load_balancer: {}, nat_traversal: { disable_assisted_addrs: false }, allow_ips_text: '' }
} }
const proxyForm = reactive({ server_id: 0, name: '', type: 'tcp' as FrpProxy['type'], local_ip: '127.0.0.1', local_port: 80, remote_port: 0, domains_text: '', locations_text: '', allow_users_text: '', metadatas_text: '', request_headers_text: '', response_headers_text: '', host_header_rewrite: '', enabled: true, remark: '', options: defaultProxyOptions() as FrpProxyOptions & { allow_ips_text?: string }, plugin_type: '', plugin_local_addr: '', plugin_unix_path: '', plugin_local_path: '', plugin_username: '', plugin_password: '' }) const proxyForm = reactive({ server_id: 0, name: '', type: 'tcp' as FrpProxy['type'], local_ip: '127.0.0.1', local_port: 80, remote_port: 0, domains_text: '', locations_text: '', allow_users_text: '', metadatas_text: '', request_headers_text: '', response_headers_text: '', host_header_rewrite: '', enabled: true, remark: '', options: defaultProxyOptions() as FrpProxyOptions & { allow_ips_text?: string }, plugin_type: '', plugin_local_addr: '', plugin_unix_path: '', plugin_local_path: '', plugin_username: '', plugin_password: '' })
+6 -2
View File
@@ -285,7 +285,10 @@
<div class="form-switch-row"> <div class="form-switch-row">
<div class="form-switch-row__text"> <div class="form-switch-row__text">
<div class="form-switch-row__label">WebSocket 支持</div> <div class="form-switch-row__label">WebSocket 支持</div>
<div class="form-switch-row__hint">附加 Upgrade / Connection 头,实时服务(家庭影院、监控等)需要</div> <div class="form-switch-row__hint">
附加 Upgrade / Connection 头。关闭后,依赖 WebSocket 的页面(NAS 桌面、各类控制台、Portainer、
Home Assistant 等)会表现为请求一直挂起、进不去;家庭影院与监控同样需要它
</div>
</div> </div>
<n-switch v-model:value="settingsForm.websocket" size="small" /> <n-switch v-model:value="settingsForm.websocket" size="small" />
</div> </div>
@@ -1054,7 +1057,8 @@ function openDeploySettings(candidate: FrpProxy) {
settingsTarget.value = candidate settingsTarget.value = candidate
settingsTab.value = 'basic' settingsTab.value = 'basic'
settingsForm.value = { settingsForm.value = {
websocket: candidate.options?.websocket ?? false, // 缺省视为开启:老规则没有这个键时按新默认走,显式关掉的仍然是关
websocket: candidate.options?.websocket ?? true,
https_enabled: !(candidate.options?.https_disabled ?? false), https_enabled: !(candidate.options?.https_disabled ?? false),
redirect_https: candidate.options?.redirect_https ?? false, redirect_https: candidate.options?.redirect_https ?? false,
client_max_body_size: candidate.options?.client_max_body_size ?? '', client_max_body_size: candidate.options?.client_max_body_size ?? '',