Nextcloud允许不被信任的域访问 取消 trusted domains
在服务器部署了Nextcloud,由于测试需要,经常从不同的地址访问,但是每次访问都要把域名添加到受信任域,反反复复修改也挺麻烦,暂时又没找到通配符或者禁用的方法。
不过网上提供了一个替代方法,动态生成当前访问的域名,作为受信任的域来访问Nextcloud,很方便。
打开Nextcloud的安装目录中config/config.php,给trusted_domains添加一项即可:
'trusted_domains' => array( 0 => '127.0.0.1', 1=>preg_match('/cli/i',php_sapi_name())?'127.0.0.1':$_SERVER['SERVER_NAME'], ),
问了AI,说把上面整段代码注释掉就可以了😅😅😅,亲测无效。
不过下面这个也是AI给出的类似答案,简单多了。
-----------------
Nextcloud has been deployed on the server. Due to testing requirements, it is frequently accessed from different addresses. However, it is cumbersome to manually add the domain to the trusted domains list every time, and I haven't found a wildcard or disable method yet.
Fortunately, there is an alternative method available online. By dynamically generating the current accessed domain, it can be added as a trusted domain to access Nextcloud conveniently.
To implement this, open the config/config.php
file in the installation directory of Nextcloud and add the following line to the trusted_domains
array:
'trusted_domains' => array( // 0 => '127.0.0.1', 0 => $_SERVER['HTTP_HOST'], //根据AI回答得到的更方便的语句,比百度别人的那个简单多了,😓 ),
By doing this, the code will dynamically add the currently accessed domain to the trusted_domains
array each time, eliminating the need for manual modifications.
Please make sure to backup the config.php
file before making any changes to avoid any unexpected issues. I hope this method helps! If you have any further questions, feel free to ask.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)