Server error after adding trusted domain in config.php

Hi there,

I permanently lose access to my Nextcloud installation when adding a trusted domain in the config.php (internal server error). This problem occurs in a direct installation as well as via docker.

My system: Synology NAS 220+, Nextcloud 23, MariaDB 10.6

Here’s what the server log says:

{"reqId":"OTgKxKf6BXmiwgNLg8ZI","level":3,"time":"2022-01-14T11:03:17+00:00","remoteAddr":"93.207.80.160","user":"--","app":"PHP","method":"GET","url":"/","message":"touch(): Utime failed: Permission denied at /var/www/html/lib/private/Config.php#248","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0","version":"","exception":{"Exception":"Error","Message":"touch(): Utime failed: Permission denied at /var/www/html/lib/private/Config.php#248","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"touch(): Utime failed: Permission denied","/var/www/html/lib/private/Config.php",248]},{"file":"/var/www/html/lib/private/Config.php","line":248,"function":"touch","args":["/var/www/html/config/config.php"]},{"file":"/var/www/html/lib/private/Config.php","line":138,"function":"writeData","class":"OC\\Config","type":"->","args":[]},{"file":"/var/www/html/lib/private/SystemConfig.php","line":131,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":1119,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/base.php","line":419,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":645,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1087,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/index.php","line":34,"args":["/var/www/html/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}} {"reqId":"OTgKxKf6BXmiwgNLg8ZI","level":3,"time":"2022-01-14T11:03:17+00:00","remoteAddr":"93.207.80.160","user":"--","app":"PHP","method":"GET","url":"/","message":"fopen(/var/www/html/config/config.php): Failed to open stream: Permission denied at /var/www/html/lib/private/Config.php#249","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0","version":"","exception":{"Exception":"Error","Message":"fopen(/var/www/html/config/config.php): Failed to open stream: Permission denied at /var/www/html/lib/private/Config.php#249","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"fopen(/var/www/html/config/config.php): Failed to open stream: Permission denied","/var/www/html/lib/private/Config.php",249]},{"file":"/var/www/html/lib/private/Config.php","line":249,"function":"fopen","args":["/var/www/html/config/config.php","r+"]},{"file":"/var/www/html/lib/private/Config.php","line":138,"function":"writeData","class":"OC\\Config","type":"->","args":[]},{"file":"/var/www/html/lib/private/SystemConfig.php","line":131,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":1119,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/base.php","line":419,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":645,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1087,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/index.php","line":34,"args":["/var/www/html/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}} {"reqId":"OTgKxKf6BXmiwgNLg8ZI","level":3,"time":"2022-01-14T11:03:17+00:00","remoteAddr":"93.207.80.160","user":"--","app":"PHP","method":"GET","url":"/","message":"chmod(): Operation not permitted at /var/www/html/lib/private/Config.php#252","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0","version":"","exception":{"Exception":"Error","Message":"chmod(): Operation not permitted at /var/www/html/lib/private/Config.php#252","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"chmod(): Operation not permitted","/var/www/html/lib/private/Config.php",252]},{"file":"/var/www/html/lib/private/Config.php","line":252,"function":"chmod","args":["/var/www/html/config/config.php",416]},{"file":"/var/www/html/lib/private/Config.php","line":138,"function":"writeData","class":"OC\\Config","type":"->","args":[]},{"file":"/var/www/html/lib/private/SystemConfig.php","line":131,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":1119,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/base.php","line":419,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":645,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1087,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/index.php","line":34,"args":["/var/www/html/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}} {"reqId":"OTgKxKf6BXmiwgNLg8ZI","level":3,"time":"2022-01-14T11:03:17+00:00","remoteAddr":"93.207.80.160","user":"--","app":"index","method":"GET","url":"/","message":"Can't write into config directory!","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0","version":"","exception":{"Exception":"OCP\\HintException","Message":"Can't write into config directory!","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Config.php","line":138,"function":"writeData","class":"OC\\Config","type":"->","args":[]},{"file":"/var/www/html/lib/private/SystemConfig.php","line":131,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":1119,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","ocdnhnyrb38e"]},{"file":"/var/www/html/lib/base.php","line":419,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":645,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1087,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/index.php","line":34,"args":["/var/www/html/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Config.php","Line":256,"Hint":"This can usually be fixed by giving the webserver write access to the config directory.","CustomMessage":"--"}} {"reqId":"OTgKxKf6BXmiwgNLg8ZI","level":3,"time":"2022-01-14T11:03:17+00:00","remoteAddr":"93.207.80.160","user":"--","app":"index","method":"GET","url":"/","message":"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1 no such table: oc_appconfig","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0","version":"","exception":{"Exception":"Doctrine\\DBAL\\Exception\\TableNotFoundException","Message":"An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1 no such table: oc_appconfig","Code":1,"Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1780,"function":"convert","class":"Doctrine\\DBAL\\Driver\\API\\SQLite\\ExceptionConverter","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1719,"function":"handleDriverException","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},{"__class__":"Doctrine\\DBAL\\Query"}]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1067,"function":"convertExceptionDuringQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":[{"__class__":"Doctrine\\DBAL\\Driver\\PDO\\Exception"},"SELECT * FROM \"oc_appconfig\"",[],[]]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":236,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\"",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\"",[],[]]},{"file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":344,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":109,"function":"loadConfigValues","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":300,"function":"getApps","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/App/AppManager.php","line":127,"function":"getValues","class":"OC\\AppConfig","type":"->","args":[false,"enabled"]},{"file":"/var/www/html/lib/private/App/AppManager.php","line":216,"function":"getInstalledAppsValues","class":"OC\\App\\AppManager","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":283,"function":"isEnabledForUser","class":"OC\\App\\AppManager","type":"->","args":["theming"]},{"file":"/var/www/html/index.php","line":44,"function":"printErrorPage","class":"OC_Template","type":"::","args":["Can't write into config directory!","This can usually be fixed by giving the webserver write access to the config directory.",503]}],"File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php","Line":55,"Previous":{"Exception":"Doctrine\\DBAL\\Driver\\PDO\\Exception","Message":"SQLSTATE[HY000]: General error: 1 no such table: oc_appconfig","Code":1,"Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":87,"function":"new","class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","type":"::","args":[{"__class__":"PDOException","errorInfo":["HY000",1,"no such table: oc_appconfig"]}]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1062,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\""]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":236,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\"",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\"",[],[]]},{"file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":344,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":109,"function":"loadConfigValues","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":300,"function":"getApps","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/App/AppManager.php","line":127,"function":"getValues","class":"OC\\AppConfig","type":"->","args":[false,"enabled"]},{"file":"/var/www/html/lib/private/App/AppManager.php","line":216,"function":"getInstalledAppsValues","class":"OC\\App\\AppManager","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":283,"function":"isEnabledForUser","class":"OC\\App\\AppManager","type":"->","args":["theming"]},{"file":"/var/www/html/index.php","line":44,"function":"printErrorPage","class":"OC_Template","type":"::","args":["Can't write into config directory!","This can usually be fixed by giving the webserver write access to the config directory.",503]}],"File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php","Line":26,"Previous":{"Exception":"PDOException","Message":"SQLSTATE[HY000]: General error: 1 no such table: oc_appconfig","Code":"HY000","Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","line":82,"function":"query","class":"PDO","type":"->","args":["SELECT * FROM \"oc_appconfig\""]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":1062,"function":"query","class":"Doctrine\\DBAL\\Driver\\PDO\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\""]},{"file":"/var/www/html/lib/private/DB/Connection.php","line":236,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\"",[],[],null]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":345,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->","args":["SELECT * FROM \"oc_appconfig\"",[],[]]},{"file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php","line":287,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":344,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":109,"function":"loadConfigValues","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":300,"function":"getApps","class":"OC\\AppConfig","type":"->","args":[]},{"file":"/var/www/html/lib/private/App/AppManager.php","line":127,"function":"getValues","class":"OC\\AppConfig","type":"->","args":[false,"enabled"]},{"file":"/var/www/html/lib/private/App/AppManager.php","line":216,"function":"getInstalledAppsValues","class":"OC\\App\\AppManager","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":283,"function":"isEnabledForUser","class":"OC\\App\\AppManager","type":"->","args":["theming"]},{"file":"/var/www/html/index.php","line":44,"function":"printErrorPage","class":"OC_Template","type":"::","args":["Can't write into config directory!","This can usually be fixed by giving the webserver write access to the config directory.",503]}],"File":"/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php","Line":82}},"CustomMessage":"--"}}

I want to access Nextcloud via a reverse proxy (subdomain of the Synology DDNS to localhost). The problem remains the same when making the changes undone.

Can anyone give me a hint why this happens and how to solve it?