CollaboraOnline / richdocumentscode

Built-in CODE Server app
https://apps.nextcloud.com/apps/richdocumentscode
Apache License 2.0
121 stars 29 forks source link

Built in CODE server incompatible wiht uwsgi in nextcloud? #228

Open naclander opened 1 year ago

naclander commented 1 year ago

I am running nextcloud using uwsgi as recommended in the Arch Linux article. This means I have a slightly modified nginx configuration file like so:

...
# stuff
...
    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;

        include uwsgi_params;
        uwsgi_modifier1 14;
        # Avoid duplicate headers confusing OC checks
        uwsgi_hide_header X-Frame-Options;
        uwsgi_hide_header X-XSS-Protection;
        uwsgi_hide_header X-Content-Type-Options;
        uwsgi_hide_header X-Robots-Tag;
        uwsgi_hide_header X-Download-Options;
        uwsgi_hide_header X-Permitted-Cross-Domain-Policies;
        uwsgi_pass unix:/run/nextcloud/nextcloud.sock;
...
# more stuff
...

Presumably the Collabora built in CODE server works when provided the recommended nginx config from nextcloud but it does not seem to work for me when modifying the nginx config as above.

Looking at nextcloud/nextcloud.log, I see the following error ( formatted for readability )

{
  "reqId": "RXD329HE6QsILOrawoa3",
  "level": 3,
  "time": "2023-06-15T06:06:50+00:00",
  "remoteAddr": "10.9.1.1",
  "user": "nac",
  "app": "richdocuments",
  "method": "POST",
  "url": "/index.php/apps/richdocuments/ajax/admin.php",
  "message": "Failed to fetch the Collabora capabilities endpoint: Client error: `GET https://nextcloud.domain.com/wapps/richdocumentscode/proxy.php?req=/hosting/capabilities` resulted in a `403 Forbidden` response:\nForbidden\n",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0",
  "version": "26.0.2.1",
  "exception": {
    "Exception": "GuzzleHttp\\Exception\\ClientException",
    "Message": "Client error: `GET https://nextcloud.domain.com/wapps/richdocumentscode/proxy.php?req=/hosting/capabilities` resulted in a `403 Forbidden` response:\nForbidden\n",
    "Code": 403,
    "Trace": [
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php",
        "line": 69,
        "function": "create",
        "class": "GuzzleHttp\\Exception\\RequestException",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 204,
        "function": "GuzzleHttp\\{closure}",
        "class": "GuzzleHttp\\Middleware",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 153,
        "function": "callHandler",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "::"
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/TaskQueue.php",
        "line": 48,
        "function": "GuzzleHttp\\Promise\\{closure}",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "::",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 248,
        "function": "run",
        "class": "GuzzleHttp\\Promise\\TaskQueue",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 224,
        "function": "invokeWaitFn",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 269,
        "function": "waitIfPending",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 226,
        "function": "invokeWaitList",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/promises/src/Promise.php",
        "line": 62,
        "function": "waitIfPending",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php",
        "line": 187,
        "function": "wait",
        "class": "GuzzleHttp\\Promise\\Promise",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/Http/Client/Client.php",
        "line": 226,
        "function": "request",
        "class": "GuzzleHttp\\Client",
        "type": "->"
      },
      {
        "file": "/var/lib/nextcloud/apps/richdocuments/lib/Service/CapabilitiesService.php",
        "line": 135,
        "function": "get",
        "class": "OC\\Http\\Client\\Client",
        "type": "->"
      },
      {
        "file": "/var/lib/nextcloud/apps/richdocuments/lib/Service/CapabilitiesService.php",
        "line": 73,
        "function": "refetch",
        "class": "OCA\\Richdocuments\\Service\\CapabilitiesService",
        "type": "->"
      },
      {
        "file": "/var/lib/nextcloud/apps/richdocuments/lib/AppInfo/Application.php",
        "line": 80,
        "function": "getCapabilities",
        "class": "OCA\\Richdocuments\\Service\\CapabilitiesService",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/Bootstrap/FunctionInjector.php",
        "line": 66,
        "function": "OCA\\Richdocuments\\AppInfo\\{closure}",
        "class": "OCA\\Richdocuments\\AppInfo\\Application",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/Bootstrap/BootContext.php",
        "line": 50,
        "function": "injectFn",
        "class": "OC\\AppFramework\\Bootstrap\\FunctionInjector",
        "type": "->"
      },
      {
        "file": "/var/lib/nextcloud/apps/richdocuments/lib/AppInfo/Application.php",
        "line": 135,
        "function": "injectFn",
        "class": "OC\\AppFramework\\Bootstrap\\BootContext",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php",
        "line": 200,
        "function": "boot",
        "class": "OCA\\Richdocuments\\AppInfo\\Application",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/legacy/OC_App.php",
        "line": 213,
        "function": "bootApp",
        "class": "OC\\AppFramework\\Bootstrap\\Coordinator",
        "type": "->"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/private/legacy/OC_App.php",
        "line": 141,
        "function": "loadApp",
        "class": "OC_App",
        "type": "::"
      },
      {
        "file": "/usr/share/webapps/nextcloud/lib/base.php",
        "line": 1038,
        "function": "loadApps",
        "class": "OC_App",
        "type": "::"
      },
      {
        "file": "/usr/share/webapps/nextcloud/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/usr/share/webapps/nextcloud/3rdparty/guzzlehttp/guzzle/src/Exception/RequestException.php",
    "Line": 113,
    "message": "Failed to fetch the Collabora capabilities endpoint: Client error: `GET https://nextcloud.domain.com/wapps/richdocumentscode/proxy.php?req=/hosting/capabilities` resulted in a `403 Forbidden` response:\nForbidden\n",
    "exception": {},
    "CustomMessage": "Failed to fetch the Collabora capabilities endpoint: Client error: `GET https://nextcloud.domain.com/wapps/richdocumentscode/proxy.php?req=/hosting/capabilities` resulted in a `403 Forbidden` response:\nForbidden\n"
  }
}

I assume nginx is not parsing and modofying the url nextcloud is trying to reach collabora built in code server on: https://nextcloud.domain.com/wapps/richdocumentscode/proxy.php?req=/hosting/capabilities.

Is there any advice on how I can make this work? Is nextcloud/collabora doing the right thing here? Because the rest of the functionality ( and other apps ) in nextcloud seem to work fine.

joshtrichards commented 1 year ago

Hi @naclander -

Arch Linux doesn't have that rewrite line in their example config (though I'm unclear why). Maybe they had a good reason. Either way, it's not something supported officially by Nextcloud and this is a forum for reporting bugs not general troubleshooting assistance.

As this is a configuration issue, I'd suggest posting this at the Nextcloud Help Forum or maybe - better yet - the Arch Linux one because that is an configuration that seems to be coming up because of what they're suggesting on their Wiki.

General troubleshooting hints:

naclander commented 1 year ago

Are you saying uwsgi is not supported?