Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: Collabora Online Development Edition & Nextcloud support #218878

Open
turion opened this issue Feb 28, 2023 · 28 comments
Open

Package request: Collabora Online Development Edition & Nextcloud support #218878

turion opened this issue Feb 28, 2023 · 28 comments
Labels
0.kind: packaging request Request for a new package to be added

Comments

@turion
Copy link
Contributor

turion commented Feb 28, 2023

Project description

Collaborative online document editing software. In particular, it should be possible to integrate this into a Nextcloud server. (CC Nextcloud maintainers @schneefux @bachp @globin @Ma27)

See an example where someone integrated this with Nextcloud, but Collabora in a docker container:
https://discourse.nixos.org/t/does-someone-run-nextcloud-onlyoffice/25382/2?u=turion

Ideally one could do services.nextcloud.code.enable = true; and there would be collabora support.

Metadata

@turion turion added the 0.kind: packaging request Request for a new package to be added label Feb 28, 2023
@Steinhagen
Copy link
Contributor

This would be really useful to have packaged for easy deployments.

@montchr
Copy link
Member

montchr commented Aug 21, 2023

Agreed, especially since Hetzner's managed Nextcloud instances (Storage Share) essentially requires the user to provide their own Collabora instance (their recommendations for OnlyOffice are no longer supported on the latest Nextcloud version).

@montchr
Copy link
Member

montchr commented Aug 21, 2023

Turns out there's some detailed documentation on the installation and configuration process, which was somewhat difficult to find from the project's website:

https://sdk.collaboraonline.com/docs/installation/index.html

@EricTheMagician
Copy link
Contributor

There's more info on how to build it here:
https://collaboraonline.github.io/post/build-code/#build-code-n-lo

I started building the collabora variant of libreoffice and I'm running in to some issues with tests. It's not much so far but hopefully I can get it working in the next few weeks / months.

@amalgame21
Copy link
Contributor

amalgame21 commented Mar 4, 2024

Any progress?
I attempted to install Nextcloud office with both Built-in CODE Server and collabora/code docker, both unsuccessful.

@EricTheMagician
Copy link
Contributor

Progress is mostly stalled:
https://github.com/EricTheMagician/nixpkgs/tree/collabora

I've managed to package it up, but the service it self doesn't work because COOL will run each user instance in a chroot environment and I've been stalled on that front.

@diogotcorreia
Copy link
Member

@EricTheMagician Any progress?
If you want, feel free to open a draft PR (is there already one?) so we can chime in and help!

@EricTheMagician EricTheMagician mentioned this issue May 1, 2024
13 tasks
@EricTheMagician
Copy link
Contributor

@EricTheMagician Any progress? If you want, feel free to open a draft PR (is there already one?) so we can chime in and help!

No progress. I've been stuck on it for awhile.

@diogotcorreia
Copy link
Member

Thank you! When I have some time (perhaps next week) I can try to help :)

Atemu added a commit to Atemu/nixpkgs that referenced this issue May 24, 2024
This is the "Nextcloud Office" app that offers Collabora CODE integration.

You still need Collabora CODE itself running somewhere but this is one step
towards NixOS#218878.
github-actions bot pushed a commit that referenced this issue May 26, 2024
This is the "Nextcloud Office" app that offers Collabora CODE integration.

You still need Collabora CODE itself running somewhere but this is one step
towards #218878.

(cherry picked from commit 04445ac)
github-actions bot pushed a commit that referenced this issue May 26, 2024
This is the "Nextcloud Office" app that offers Collabora CODE integration.

You still need Collabora CODE itself running somewhere but this is one step
towards #218878.

(cherry picked from commit 04445ac)
Atemu added a commit to Atemu/nixpkgs that referenced this issue May 28, 2024
This is the "Nextcloud Office" app that offers Collabora CODE integration.

You still need Collabora CODE itself running somewhere but this is one step
towards NixOS#218878.

(cherry picked from commit 04445ac)
(cherry picked from commit 373986b)
Sobte pushed a commit to Sobte/nixpkgs that referenced this issue May 28, 2024
This is the "Nextcloud Office" app that offers Collabora CODE integration.

You still need Collabora CODE itself running somewhere but this is one step
towards NixOS#218878.
mradalbert pushed a commit to mradalbert/nixpkgs that referenced this issue May 30, 2024
This is the "Nextcloud Office" app that offers Collabora CODE integration.

You still need Collabora CODE itself running somewhere but this is one step
towards NixOS#218878.

(cherry picked from commit 04445ac)
@balintbarna
Copy link

Adding my +1, I'm running a Nextcloud server on a Hetzner VPS and a network mounted Storage Box. Everything works perfectly and my setup is not too complicated, however the OCI container for Collabora CODE takes up 2GB of my scarce SSD space and I assume it's not as efficient on RAM and CPU either. If I could easily add a Nix packaged alternative with 2-3 lines of configuration to my NixOS container on the VPS it could make it much leaner.

@botsarenthuman
Copy link

Is it possible to compile the non-CODE version?

@amalgame21
Copy link
Contributor

amalgame21 commented Oct 8, 2024

@EricTheMagician Seems libreoffice-collabora and Collabora Online is already merged into nixpkgs.
Good news!
#329525
#330708

(CC Nextcloud maintainers @schneefux @bachp @globin @Ma27)

@Atemu Atemu closed this as completed Oct 9, 2024
@dotlambda
Copy link
Member

Nextcloud support hasn't been implemented yet afaik.

@dotlambda dotlambda reopened this Oct 9, 2024
@bachp
Copy link
Member

bachp commented Oct 10, 2024

@dotlambda I'm not sure if there is anything needed on the nextcloud side. I haven't tried the Nextcloud Office app, but for OnlyOffice it is basically just running the server and then configuring the OnlyOffice app to point to that server.

I assume it's similar for Nextcloud Office.

@balintbarna
Copy link

I haven’t tested this package yet because I didn’t have time but I’ve been using Nextcloud office with the CODE docker image and it’s been working fine. I assume it would be a similar setup with this package. Of course it would be nice to have a one liner config for the Nextcloud server to automatically include and set up CODE. 😊

@amalgame21
Copy link
Contributor

amalgame21 commented Oct 10, 2024

deleted spams

It may help people like me if there is nextcloud support.

@amalgame21
Copy link
Contributor

I haven’t tested this package yet because I didn’t have time but I’ve been using Nextcloud office with the CODE docker image and it’s been working fine. I assume it would be a similar setup with this package. Of course it would be nice to have a one liner config for the Nextcloud server to automatically include and set up CODE. 😊

May I ask which version of CODE docker image are you using?

@balintbarna
Copy link

I haven’t tested this package yet because I didn’t have time but I’ve been using Nextcloud office with the CODE docker image and it’s been working fine. I assume it would be a similar setup with this package. Of course it would be nice to have a one liner config for the Nextcloud server to automatically include and set up CODE. 😊

May I ask which version of CODE docker image are you using?

I think this is my active config
https://codeberg.org/balint/nixos-configs/src/branch/nextcloud/hosts/vps/nextcloud.nix

@turion
Copy link
Contributor Author

turion commented Oct 11, 2024

I also have a CODE docker config, https://gitlab.com/turion/enigmanix/-/blob/master/specific/manuelbaerenz/nextcloud/collabora.nix?ref_type=heads, which is copied together from blog posts.

@jsimonetti
Copy link
Contributor

I actually use the CODE appimage, which I assume will be similar to the merged PR:
https://gist.github.com/jsimonetti/d3a006b399b3e6f681cad5d694812f98

@amalgame21
Copy link
Contributor

amalgame21 commented Oct 12, 2024

I haven’t tested this package yet because I didn’t have time but I’ve been using Nextcloud office with the CODE docker image and it’s been working fine. I assume it would be a similar setup with this package. Of course it would be nice to have a one liner config for the Nextcloud server to automatically include and set up CODE. 😊

May I ask which version of CODE docker image are you using?

I think this is my active config https://codeberg.org/balint/nixos-configs/src/branch/nextcloud/hosts/vps/nextcloud.nix

Thanks for sharing this! Really appreciated, so now I am sure the package/image is not the cause of the issue in my setup.
EDIT: Nextcloud Office successfully run with the Nixpkgs collabora online package in my double NAT setup, when the CODE port 9980 is tunnelled to outside world and using that URL as WOPI URL.
Thanks for your help!

@amalgame21
Copy link
Contributor

amalgame21 commented Oct 13, 2024

I actually use the CODE appimage, which I assume will be similar to the merged PR: https://gist.github.com/jsimonetti/d3a006b399b3e6f681cad5d694812f98

This is it!!! Thank you for your config!!!!
After days of testing, I finally use this config to make the reverse proxy working! The double NAT in my setup is not the actual problem because I already setup the split DNS.

The actual problem is, the official guide of collabora online nginx reverse proxy setup did NOT work well with NixOS!
I think the problem is related to the order of locations block in the nginx.conf:

After directly applying the official nginx reverse proxy setting (SSL termination) into NixOS, after a nixos-rebuild and I found that the locations block in the actual nginx.conf in nix store is no longer in the original order, and the location ~ ^/(c|l)ool { ... } block is now above location ~ ^/cool/(.*)/ws$ { ... }.
I can see in the log that the actually websocket wss:// is ending with /ws$ and starting with /cool. I think it also matches location ~ ^/(c|l)ool { ... } and go into this block instead of location ~ ^/cool/(.*)/ws$ { ... } block because of the locations block order in nginx.conf (not sure).
The websocket proxy related settings in the location ~ ^/(c|l)ool { ... } block have not be applied, soI think it is probably the reason of 400 bad request and reverse proxy failed.

In your config, the websocket proxy related settings are also applied in the location ~ ^/(c|l)ool { ... } block, so this config works.

EDIT: Tested solely to use the services.nginx.virtualHosts.<name>.extraConfig option to keep all the locations block in the right order in the final nginx.conf, and it worked, no need to add websocket proxy related settings into location ~ ^/(c|l)ool { ... }.

Hope this help for someone who encounter the same problem.

@jsimonetti
Copy link
Contributor

I have no idea if what you mention was me working around the same problem. It has been too long ago since I configured this, so it could very well be.

I don't think there is a way to influence the location block order.

@456634
Copy link

456634 commented Nov 12, 2024

Hi everyone. I've been trying for days now to connect Collabora from the unstable channel to my Nextcloud. I've encountered multiple issues, including problems with the proxy settings. In parallel, I also set up the Docker image for testing purposes as described here (though I had to adjust the proxy configuration here as well):
https://discourse.nixos.org/t/enabling-nextcloud-office/31349/3

1. Proxy Settings
I resolved the issue mentioned by @amalgame21 regarding the order of locations by using priority (the default priority is 1000). I'm not sure if this is the correct solution or just a symptom fix. Without setting the priority to 1001, Nextcloud cannot open documents and reports an error with the proxy settings.

2. Error Messages When Opening a Document (after proxy fix)

coolwsd[761422]: wsd-761422-761661 2024-11-12 18:35:05.273980 +0100 [ websrv_poll ] ERR  FileServerRequestHandler: File not found: Invalid URI request: [/browser/24.04.6.1/branding.css].| wsd/FileServer.cpp:747
coolwsd[761422]: wsd-761422-761661 2024-11-12 18:35:05.274194 +0100 [ websrv_poll ] ERR  FileServerRequestHandler: File not found: Invalid URI request: [/browser/24.04.6.1/branding.js].| wsd/FileServer.cpp:747
coolwsd[761422]: wsd-761422-761661 2024-11-12 18:35:05.306096 +0100 [ websrv_poll ] ERR  FileServerRequestHandler: File not found: Invalid URI request: [/browser/24.04.6.1/branding-desktop.css].| wsd/FileServer.cpp:747

I don’t get these messages with the Docker image. So far, I haven’t been able to determine if this has any impact.

3. PDF Conversion, Downloading, and Printing Not Possible

coolwsd[761702]: frk-761620-761620 2024-11-12 18:13:56.621970 +0100 [ forkit ] INF  Forkit initialization complete: setting log-level to [warning] as configured.| kit/ForKit.cpp:828
coolwsd[761702]: kit-761702-761702 2024-11-12 18:37:31.780728 +0100 [ kitbroker_002 ] ERR  ToMaster-014: error: cmd=exportas kind=saveasfailed| common/Session.hpp:172
coolwsd[761702]: kit-761702-761702 2024-11-12 18:37:31.780766 +0100 [ kitbroker_002 ] ERR  ToMaster-014: CALLBACK_ERROR: {
coolwsd[761702]:     "code": "0x20d(Error Area:Io Class:General Code:13) arg1=SfxBaseModel::impl_store <file:\/\/\/tmp\/New%20document.pdf> failed: 0xc10(Error Area:Io Class:Write Code:16) at \/build\/core\/sfx2\/source\/doc\/sfxbasemodel.cxx:3277 at \/build\/core\/sfx2\/source\/doc\/sfxbasemodel.cxx:1825",
coolwsd[761702]:     "kind": "",
coolwsd[761702]:     "cmd": "",
coolwsd[761702]:     "message": "General Error.\nGeneral input\/output error."
coolwsd[761702]: }
coolwsd[761702]: | kit/ChildSession.cpp:3339
coolwsd[761702]: kit-761702-761702 2024-11-12 18:37:31.780795 +0100 [ kitbroker_002 ] ERR  ToMaster-014: error: cmd= kind= code=0x20d(Error Area:Io Class:General Code:13) arg1=SfxBaseModel::impl_store <file:///tmp/New%20document.pdf> failed: 0xc10(Error Area:Io Class:Write Code:16) at /build/core/sfx2/source/doc/sfxbasemodel.cxx:3277 at /build/core/sfx2/source/doc/sfxbasemodel.cxx:1825| common/Session.hpp:166
coolwsd[761422]: wsd-761422-762689 2024-11-12 18:37:31.780917 +0100 [ docbroker_002 ] ERR  ToClient-014: exportas error failure: saveasfailed| wsd/ClientSession.cpp:1885
coolwsd[761422]: wsd-761422-762689 2024-11-12 18:37:31.780972 +0100 [ docbroker_002 ] ERR  ToClient-014:  error failure: | wsd/ClientSession.cpp:1885

Printing in general, as well as converting and downloading PDFs, is not possible. This works without any issues in the Docker image.

Overall, the Docker image seems to work fine except for the proxy fix.

There’s only one message which, to me, seems more like a Docker issue (update: fixed)
collabora[733757]: frk-00019-00019 2024-11-12 17:09:30.433812 +0000 [ forkit ] WRN  The systemplate directory [/opt/cool/systemplate] is read-only, and at least [/opt/cool/systemplate//etc/hosts] is out-of-date. Will have to clone dynamic elements of systemplate to the jails. To restore optimal performance, make sure the files in [/opt/cool/systemplate/etc] are up-to-date.| common/JailUtil.cpp:585

(I’m not familiar with Docker and didn’t want to change it).
Fix this with:

podman exec -u 0 <container-id-oder-name> coolconfig update-system-template
Nextcloud Config
{config, pkgs, ...}: let cfg = config.services.nextcloud; in {
      services.nextcloud = {
        enable = true;
        package = pkgs.nextcloud29;
        hostName = "cloud.<domain>.com";
        database.createLocally = true;
        config = {
          dbtype = "mysql";
          adminuser = "admin";
          adminpassFile = "/etc/nextcloud-admin-pass";
        };
        configureRedis = true;
        phpOptions = {
          "opcache.interned_strings_buffer" = "64";
          "opcache.memory_consumption" = "256";
        };
        settings = {
          log_type = "syslog";
          default_locale = "de_DE";
          default_phone_region = "DE";
          allow_user_to_change_display_name = true;
          maintenance_window_start = 3;
        };
        https = true;
        appstoreEnable = true;
        autoUpdateApps.enable = true;
      };

      services.nginx.virtualHosts.${cfg.hostName} = {
        forceSSL = true;
        enableACME = true;
      };
    }
Collabora Config
{config, lib, pkgs-unstable, ...}: {     
      imports = ["${nixpkgs-unstable}/nixos/modules/services/web-apps/collabora-online.nix"];      
      services.collabora-online = {
        enable = true;
        port = 9980;
        aliasGroups = [{
          host = "https://cool.<domain>.com"; 
          aliases = ["https://cloud.<domain>.com:443"];
        }];
        extraArgs = [
          "--o:ssl.enable=false"
          "--o:ssl.termination=true"        
        ];
        package = pkgs-unstable.collabora-online;
      };
     
      services.nginx.virtualHosts."cool.<domain>.com" = {
        forceSSL = true;
        enableACME = true;
        locations = let proxyPass = "http://127.0.0.1:9980"; in {
          # static files
          "^~ /browser".proxyPass = proxyPass;
         
          # WOPI discovery URL
          "^~ /hosting/discovery".proxyPass = proxyPass;
          
          # Capabilities
          "^~ /hosting/capabilities".proxyPass = proxyPass;
          
          # main websocket
          "~ ^/cool/(.*)/ws$" = {
            proxyPass = proxyPass;
            proxyWebsockets = true;
          };
          
          # download, presentation and image upload
          "~ ^/(c|l)ool" = {
            proxyPass = proxyPass;
            priority = 1001;
          };
          
          # Admin Console websocket
          "^~ /cool/adminws" = {
            proxyPass = proxyPass;
            proxyWebsockets = true;
          };
        };
      };
    }
Nginx Config
      services.nginx = {
        enable = true;
        recommendedGzipSettings = true;
        recommendedProxySettings = true;
        recommendedTlsSettings = true;
        appendHttpConfig = ''server_names_hash_bucket_size 64;'';
        virtualHosts.default = {
          default = true;
          rejectSSL = true;
          locations."/".return = "404";
        };
      };
      systemd.services.nginx.serviceConfig = {
        ReadWritePaths = ["/var/www"];
        ProtectHome = "read-only";
      };
      networking.firewall.allowedTCPPorts = [80 443];

Can anyone confirm these issues with the pkgs or shed some light on them otherwise?
Thanks, and in general, thank you for providing the package @xzfc

@ambroisie
Copy link
Contributor

@456634 I've been able to configure nginx with a singular / location with proxyPass, and both websockets locations with proxyPass and proxyWebsockets. Are the other locations really mandatory then? I avoided needing to set priority that way.


I can confirm that I also see the errors about the branding files or when trying to export to PDF.

Additionally, I also see some Socket write returned -1 (EPIPE: Broken pipe)| net/Socket.hpp:1484 errors which I haven't been able to correlate with my actions in Nextcloud.

@456634
Copy link

456634 commented Nov 16, 2024

Hi @ambroisie , to be honest, I can’t say too much about this. Generally, I think it’s a good practice to follow the developers’ configuration guidelines initially. As I understand it, nginx respects the order of locations after "^~". Therefore, we apparently need to ensure that this order is also maintained under Nix, which we can achieve using priority. However, why the order of locations isn’t respected under Nix, I unfortunately can’t explain at this point.

@hannesg
Copy link

hannesg commented Nov 24, 2024

I also had to set the listening interface of collabora to loopback because it picked the wrong interface on my server by default:

  services.collabora-online = {
    enable = true;
    settings = {
      net.listen = "loopback";
    };
  };

Maybe that would also make for a good default setting?

I'm currently trying to find out why printing is not working. I figured out at least that Error Area:Io Class:Write Code:16 means ERRCODE_IO_CANTWRITE.

@hannesg
Copy link

hannesg commented Nov 27, 2024

More findings:

I obtained a system trace and the last thing collabora does before failing to print is trying to access "/var/lib/cool/systemplate/lo/unorc" which does not exist. The directory "/var/lib/cool/systemplate/lo" just contains a symlink called "lo" pointing to "../../../../lo" . I tried to figure out where this file is created and it should come from the coolwsd-systemplate-setup.service systemd unit. The underlying script is can be seen here and it looks like it would be really hard to get it running in nixos.

Indeed, I enabled bash -x logging and found this:

Nov 27 00:51:44 granogayo bash[3473]: + mkdir -p /var/lib/cool/systemplate/lo
Nov 27 00:51:44 granogayo bash[3473]: + for path in $INSTDIR $INSTDIR_LOGICAL
Nov 27 00:51:44 granogayo bash[3534]: ++ dirname /var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib/collaboraoffice
Nov 27 00:51:44 granogayo bash[3473]: + INSTDIR_PARENT=/var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib
Nov 27 00:51:44 granogayo bash[3473]: + mkdir -p /var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib
Nov 27 00:51:44 granogayo bash[3536]: ++ realpath --relative-to=/var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib /var/lib/cool/systemplate/lo
Nov 27 00:51:44 granogayo bash[3473]: + ln -f -s ../../../../lo /var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib/collaboraoffice
Nov 27 00:51:44 granogayo bash[3473]: + for path in $INSTDIR $INSTDIR_LOGICAL
Nov 27 00:51:44 granogayo bash[3538]: ++ dirname /var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib/collaboraoffice
Nov 27 00:51:44 granogayo bash[3473]: + INSTDIR_PARENT=/var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib
Nov 27 00:51:44 granogayo bash[3473]: + mkdir -p /var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib
Nov 27 00:51:44 granogayo bash[3540]: ++ realpath --relative-to=/var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib /var/lib/cool/systemplate/lo
Nov 27 00:51:44 granogayo bash[3473]: + ln -f -s ../../../../lo /var/lib/cool/systemplate//nix/store/qrxilbwcli3jq63sz8j20agsvsnpmlx4-libreoffice-24.04.5-4/lib/collaboraoffice

The script creates the symlink twice. The second time, it figures out that the name is a directory and creates a file inside the directory instead of the file itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.