公网反代默认转发 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
+4 -1
View File
@@ -831,7 +831,10 @@ const editingProxy = ref<FrpProxy | null>(null)
const downloadPolling = ref(false)
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: '' })
+6 -2
View File
@@ -285,7 +285,10 @@
<div class="form-switch-row">
<div class="form-switch-row__text">
<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>
<n-switch v-model:value="settingsForm.websocket" size="small" />
</div>
@@ -1054,7 +1057,8 @@ function openDeploySettings(candidate: FrpProxy) {
settingsTarget.value = candidate
settingsTab.value = 'basic'
settingsForm.value = {
websocket: candidate.options?.websocket ?? false,
// 缺省视为开启:老规则没有这个键时按新默认走,显式关掉的仍然是关
websocket: candidate.options?.websocket ?? true,
https_enabled: !(candidate.options?.https_disabled ?? false),
redirect_https: candidate.options?.redirect_https ?? false,
client_max_body_size: candidate.options?.client_max_body_size ?? '',