Files
MemRelay/projects/d1932ed6-07d3-4463-a224-8534ffd69a07/reconfigure 覆盖 trusted_domains 通配项的问题与修复.md
T

28 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: reconfigure 覆盖 trusted_domains 通配项的问题与修复
type: experience
permalink: main/projects/d1932ed6-07d3-4463-a224-8534ffd69a07/reconfigure-覆盖-trusted-domains-通配项的问题与修复
stable_id: f42fc721-886f-4d6d-85a4-1611d7bc2cf1
scope: project
project_id: d1932ed6-07d3-4463-a224-8534ffd69a07
memory_type: experience
status: active
revision: 1
restored_from_commit: 6a6a895eafcca6052e81a14fca103a42635dd1c2
created_at: '2026-09-23T15:05:35.024462+00:00'
updated_at: '2026-09-23T15:05:35.024528+00:00'
tags:
- nextoffice
- reconfigure
- trusted_domains
- manage.py
- bugfix
---
问题:manage.py reconfigure 原来只执行 `occ config:system:set trusted_domains 0 --value=新IP:端口`,而 deploy.py 安装时的布局是索引 0=`#^.+$#`(接受任意 Host 的正则通配)、1=nextcloud、2=localhost、3=IP:端口。换 IP 后通配项被覆盖、旧地址残留在索引 3,导致“允许通过其他 IP/主机名访问”失效。
修复(提交 e1154e5):在 deploy.py 抽出 `configure_access_urls(host, nextcloud_port, onlyoffice_port)`,统一写 trusted_domains 0..3、overwrite.cli.url、onlyoffice DocumentServerUrl;deploy.configure 和 manage.reconfigure 都调用它,不再手工对齐索引。reconfigure 同时改为 `compose up -d --wait`(HOST_IP 变化会改变 NEXTCLOUD_TRUSTED_DOMAINS 环境变量、端口变化会改变映射,Compose 会重建容器,需等健康后再跑 occ;本机 Compose v5.3.1 支持 --wait),并用 deploy 的 prompt_value/validate_ipv4 校验新 IP,非法 IP(如 0.0.0.0)在写 .env 前就拒绝。
旧实例修复方式:再执行一次 `python3 manage.py reconfigure` 即可,因为会完整重写 4 个索引;docs/TROUBLESHOOTING.md 已补充说明(docs/ 不入库)。
验证方法:用 mock 的 occ/compose 执行 deploy.configure 和 manage.reconfigure,断言 occ 调用序列(trusted_domains 恰好 4 次、索引 0 为通配、索引 3 为 IP:端口),以及 .env 重写内容。