Nextcloud Office with Built-in CODE Server is not working

Hello,

I am trying to test Nextcloud Office with Built-in CODE Server and it does not work.

I get error message on UI:
Could not establish connection to the Collabora Online server. This might be due to a missing configuration of your web server. For more information, please visit: Connecting Collabora Online Single Click with Nginx

Error log shows this:

Apr 25 21:22:19 syncloud Nextcloud[6021]: {"reqId":"OeNKsHIWSteF6DAiDXbb","level":3,"time":"2022-04-25T21:22:19+00:00","remoteAddr":"****","user":"boris","app":"PHP","method":"POST","url":"/index.php/apps/richdoc
uments/ajax/admin.php","message":"{\"Exception\":\"Error\",\"Message\":\"Trying to access array offset on value of type null at /var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/DiscoveryManager.php#123\",\"Code\"
:0,\"Trace\":[{\"file\":\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/DiscoveryManager.php\",\"line\":123,\"function\":\"onError\",\"class\":\"OC\\\\Log\\\\ErrorHandler\",\"type\":\"::\",\"args\":[2,\"Trying
 to access array offset on value of type null\",\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/DiscoveryManager.php\",123]},{\"file\":\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/DiscoveryManag
er.php\",\"line\":80,\"function\":\"isProxyStarting\",\"class\":\"OCA\\\\Richdocuments\\\\WOPI\\\\DiscoveryManager\",\"type\":\"->\",\"args\":[\"https://nextcloud.example.com/extra-apps/richdocumentscode/proxy.php?r
eq=/hosting/discovery\"]},{\"file\":\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/DiscoveryManager.php\",\"line\":56,\"function\":\"fetchFromRemote\",\"class\":\"OCA\\\\Richdocuments\\\\WOPI\\\\DiscoveryMana
ger\",\"type\":\"->\",\"args\":[]},{\"file\":\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/Parser.php\",\"line\":41,\"function\":\"get\",\"class\":\"OCA\\\\Richdocuments\\\\WOPI\\\\DiscoveryManager\",\"type\
":\"->\",\"args\":[]},{\"file\":\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/Controller/SettingsController.php\",\"line\":176,\"function\":\"getUrlSrc\",\"class\":\"OCA\\\\Richdocuments\\\\WOPI\\\\Parser\",\"typ
e\":\"->\",\"args\":[\"Capabilities\"]},{\"file\":\"/snap/nextcloud/484/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\",\"line\":217,\"function\":\"setSettings\",\"class\":\"OCA\\\\Richdocuments\\\\Controller\\\\
SettingsController\",\"type\":\"->\",\"args\":[\"https://nextcloud.example.com/extra-apps/richdocumentscode/proxy.php?req=\",null,false,null,null,null,null,null]},{\"file\":\"/snap/nextcloud/484/nextcloud/lib/privat
e/AppFramework/Http/Dispatcher.php\",\"line\":126,\"function\":\"executeController\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\"->\",\"args\":[{\"__class__\":\"OCA\\\\Richdocuments\\\\Controller\\\\
SettingsController\"},\"setSettings\"]},{\"file\":\"/snap/nextcloud/484/nextcloud/lib/private/AppFramework/App.php\",\"line\":157,\"function\":\"dispatch\",\"class\":\"OC\\\\AppFramework\\\\Http\\\\Dispatcher\",\"type\":\
"->\",\"args\":[{\"__class__\":\"OCA\\\\Richdocuments\\\\Controller\\\\SettingsController\"},\"setSettings\"]},{\"file\":\"/snap/nextcloud/484/nextcloud/lib/private/Route/Router.php\",\"line\":302,\"function\":\"main\",\"
class\":\"OC\\\\AppFramework\\\\App\",\"type\":\"::\",\"args\":[\"OCA\\\\Richdocuments\\\\Controller\\\\SettingsController\",\"setSettings\",{\"__class__\":\"OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer\"},{\"
_route\":\"richdocuments.settings.setSettings\"}]},{\"file\":\"/snap/nextcloud/484/nextcloud/lib/base.php\",\"line\":1006,\"function\":\"match\",\"class\":\"OC\\\\Route\\\\Router\",\"type\":\"->\",\"args\":[\"/apps/richdo
cuments/ajax/admin.php\"]},{\"file\":\"/snap/nextcloud/484/nextcloud/index.php\",\"line\":36,\"function\":\"handleRequest\",\"class\":\"OC\",\"type\":\"::\",\"args\":[]}],\"File\":\"/snap/nextcloud/484/nextcloud/lib/priva
te/Log/ErrorHandler.php\",\"Line\":92,\"CustomMessage\":\"--\"}","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0","version":"23.0.2.1"}

Also I think I see the source of extra-apps/richdocuments/lib/WOPI/Parser.php in the log

Apr 25 21:22:19 syncloud Nextcloud[6021]: {"reqId":"OeNKsHIWSteF6DAiDXbb","level":3,"time":"2022-04-25T21:22:19+00:00","remoteAddr":"****","user":"boris","app":"PHP","method":"POST","url":"/index.php/apps/richdocuments/ajax/admin.php","message":"{\"Exception\":\"Error\",\"Message\":\"simplexml_load_string(): Entity: line 424: parser error : Start tag expected, '&lt;' not found at /var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/Parser.php#47\",\"Code\":0,\"Trace\":[{\"function\":\"onError\",\"class\":\"OC\\\\Log\\\\ErrorHandler\",\"type\":\"::\",\"args\":[2,\"simplexml_load_string(): Entity: line 424: parser error : Start tag expected, '&lt;' not found\",\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/Parser.php\",47]},{\"file\":\"/var/snap/nextcloud/484/extra-apps/richdocuments/lib/WOPI/Parser.php\",\"line\":47,\"function\":\"simplexml_load_string\",\"args\":[\"<?php\\n/*\\n * Copyright (C) 2020 Collabora Productivity, Ltd.\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n *      http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n

In my config.php I have this:

    'apps_paths' => array(
        array(
            'path'=> '/snap/nextcloud/current/nextcloud/apps',
            'url' => '/apps',
            'writable' => false,
        ),
        array(
            'path'=> '/var/snap/nextcloud/current/extra-apps',
            'url' => '/extra-apps',
            'writable' => true,
        ),
    ),

In my nginx config I have these key bits:

    location ~ /extra-apps/(.*)$ {
        alias /var/snap/nextcloud/current/extra-apps/$1;
    }
    ...
    location ~ \.php(?:$|/) {
    
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;
    ...

I have tried to add the mentioned nginx fix from the error message link:

    location ~ \.php(?:$|/) {
        # Required for legacy support
        rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;

        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;

But this did not seem to help.

Many other extra apps like calendar work just fine.

Switching to Use a demo server also works fine.

Switching to Use your own server suggests to use this link https://nextcloud.***/extra-apps/richdocumentscode/proxy.php?req= which actually suspiciously shows php source if I open it in a browser. Opening other apps like using a similar link https://nextcloud.***/extra-apps/calendar/appinfo/routes.php also shows php source but calendar app works.

Nextcloud: 23.0.2
Collabora Online - Built-in CODE Server 21.11.306
Nextcloud Office 5.0.3

Can someone help?