nextcloud / all-in-one

šŸ“¦ The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.
https://hub.docker.com/r/nextcloud/all-in-one
GNU Affero General Public License v3.0
5.55k stars 643 forks source link

Make collabora work behind Apache #834

Closed charredchar closed 2 years ago

charredchar commented 2 years ago

How to use GitHub

Steps to reproduce

  1. Install Nextcloud AIO following the steps in readme.md. Enable the Collabora container from the AIO Interface.
  2. Open any .docx or .odt file.

Expected behavior

Collarbora/Nextcloud Office loads the file in the browser

Actual behavior

I receive an error, "Document Loading failed. Failed to load Nextcloud Office - please try again later"

Host OS

Ubuntu Server 20.04 in a Windows Server Hyper-V VM.

Nextcloud AIO version

Nextcloud AIO v1.4.0

Current channel

Latest, attempted Beta with the same results.

Other valuable info

I am currently running Nextcloud through an Apache Reverse Proxy located on another VM. I followed the setup under reverse-proxy.md including the VirtualHosts and startup command. Everything except for Collabora works perfectly as expected. I wouldn't mind testing without a reverse proxy at all, using just the server IP, for testing but I couldn't get through the AIO setup without a domain entered. I've tried it in Edge, Chrome and Firefox. Adblock disabled.

AIO Apache Log; https://pastebin.com/7VNKQw29 AIO Nextcloud Log; https://pastebin.com/NcnBpz4C Chrome Console while loading file; https://pastebin.com/YRxkR55L AIO Collabora log is too large for Pastebin.

szaimen commented 2 years ago

@Cr0iX am I correct that you are running AIO behind Apache? If yes, is it possible for you to reproduce this issue?

Cr0iX commented 2 years ago

@Cr0iX am I correct that you are running AIO behind Apache? If yes, is it possible for you to reproduce this issue?

Yes that is correct.

I have just tried to run nextcloud-aio with collabora instead of onlyoffice, and i can confirm that the error "Document loading failed" is back. I've tried both .odt and .docx, and both have the same error.

Pulling the updates to see if stuff changes. Still same error with latest docker versions.

I get this error from nextcloud-aio-nextcloud: nextcloud-aio-apache | {"level":"error","ts":1655665353.162254,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"write tcp 172.21.0.9:11000->172.21.0.1:55152: write: broken pipe"}

szaimen commented 2 years ago

I see. Thanks for providing the log!

Can you check if adding ProxyPreserveHost On makes it work? Thank you!

Cr0iX commented 2 years ago

It doesn't. I already had that in my config.

szaimen commented 2 years ago

Thanks! No idea how to work around this then...

szaimen commented 2 years ago

Can you send your browser console logs when opening the document?

szaimen commented 2 years ago

I see @charredchar already provided this info...

szaimen commented 2 years ago

It seems like simply websockets do not work as intended...

crocobc commented 2 years ago

Hi there, just for information maybe it can help..

I had same error on Collabora at fresh install. The ONLY way i make it work is with a TRUE certificate (no self-signed...)

Maybe you can test is you use self-signed certificate.

I used true certificate (letsencrypt) with reverse proxy (haproxy) in another VM like you.

Regards

szaimen commented 2 years ago

No, we only use certificates from letsencrypt here so this should not be the problem...

szaimen commented 2 years ago

Somehow the websocket connection seems to fail. This seems to be caused by collabora not sending the upgrade websocket header nor the connection upgrade variable. But I may be wrong here since this would probably mean that it would fail behind other reverse proxies, too...

szaimen commented 2 years ago

https://github.com/nextcloud/all-in-one/pull/835 makes the push proxy work behind apache which did not work, too...

charredchar commented 2 years ago

I see. Thanks for providing the log!

Can you check if adding ProxyPreserveHost On makes it work? Thank you!

I have this enabled already as well, as it is part of the config on the reverse-proxy.md doc.

Hi there, just for information maybe it can help..

I had same error on Collabora at fresh install. The ONLY way i make it work is with a TRUE certificate (no self-signed...)

Maybe you can test is you use self-signed certificate.

I used true certificate (letsencrypt) with reverse proxy (haproxy) in another VM like you.

Regards

I have true certificates using LetsEncrypt with all subdomains through my Apache reverse proxy. I don't know what Nextcloud might be doing on the backend though as attempting to connect to IP:Port just forwards to my domain address anyway.

Should Collabora be accessible through IP:Port as well? I can not seem to access it.

szaimen commented 2 years ago

Should Collabora be accessible through IP:Port as well? I can not seem to access it.

No it shouldn'. It should just work without any additional work which is not the case because something does not work as expected with the apache reverse proxy documentation.

However curently not sure what to change to make it work.

szaimen commented 2 years ago

No, it does not necessarily need to be on a subdomain as it works for all other reverse proxies with the same domain only not for apache in front of AIO...

szaimen commented 2 years ago

I was just trying to share how I got it to work. It would be perfect if a subdomain is not needed, as this would solve the issue I mentioned above :-)

As I said it works for all reverse proxies with the same domain and only seems to be a problem with apache in front of it...

szaimen commented 2 years ago

Unfortunately I was not able to find a solution to this so some help on this is appreciated!

SamuXzX commented 2 years ago

What can we provide to try to identify the problem?

szaimen commented 2 years ago

What can we provide to try to identify the problem?

You can try to improve the reverse proxy documentation for Apache that makes Collabora that is bundled within AIO work.

SamuXzX commented 2 years ago

Do you confirm that you referred to this guide to set up a Collabora docker container? https://collabora-online-for-nextcloud.readthedocs.io/en/latest/install/

szaimen commented 2 years ago

Seems like there is now a problem with Nginx, too. We could try to downgrade the collabora container and see if it fixes the issue. Do you remember with which AIO version it worked the last time?

szaimen commented 2 years ago

If I remember cotrectly, it used to work before the aio 1.4.0 update which included a collabora upgrade. I'll try to verify this week if using the 21.11.4.2.1 collabora image works. If yes I will see if it is possible to downgrade or if there is any other solution to this

ckauhaus commented 2 years ago

Any news on this? I have the same problem here, and I cannot get Collabora working on AIO at all :-(

albert-gee commented 2 years ago

Collabora has changed their settings, here is the solution: https://help.nextcloud.com/t/solved-another-failed-to-load-collabora-online-please-try-again-later-problem/111473/39?u=esmailelbob Can it be applied to AIO?

szaimen commented 2 years ago

https://help.nextcloud.com/t/solved-another-failed-to-load-collabora-online-please-try-again-later-problem/111473/39?u=esmailelbob

This is already applied and working with all documented reverse proxies except Apache. I haven't figured out a way what needs to be changed in the Apache reverse proxy config in order to make it work. Your help in doing so is very welcome!

I am talking about changes to this config: https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md#apache

SamuXzX commented 2 years ago

We can't improve the config if we don't know what's the problem. We need some logs

szaimen commented 2 years ago

So, I made multiple attempts to find a working Apache config for this but everytime it fails to establish the websocket connection. I'll see together with @juliushaertl if we find the reason and a solution to this.

Heggeg commented 2 years ago

I have nextcloud-aio running behind nginx-proxy-manager with lets encrypt certificate.

I also have the problem in the admin settings that nextcloud thinks it can't connect to the Collabora Online server.

As soon as I adjust the URL to access it without reverse proxy the settings turn green. (http://IP:11000) But it still does not work after you press save the settings are red again and it complains that different protocols are used. (http/https)

TheManchineel commented 2 years ago

This is still a problem for me, on NGINX as well. The issue concerning NGINX has been closed for some reason. Any guidance?

szaimen commented 2 years ago

NGINX as well.

Ah interesting! I didn't know.

TheManchineel commented 2 years ago

Sample request in browser console:

GET wss://example.com/cool/https://example.com/index.php/apps/richdocuments/wopi/files/73_och226abshji?access_token=XXXX&access_token_ttl=0&permission=edit/ws?WOPISrc=https://example.com/index.php/apps/richdocuments/wopi/files/73_och226abshji&compat=/ws

returns HTTP status code 400 (bad request)

Zoey2936 commented 2 years ago

That's interesting, I run it behind my fork of the Nginx-Proxy-Manager and here collabora is working without problems.

szaimen commented 2 years ago

to everyone that has problems with it: is everyone that has problems with it not running the reverse proxy on the same server or not using localhost:11000 but instead ip-address:11000 in your reverse proxy config?

TheManchineel commented 2 years ago

@szaimen I'm using Unraid so you're not "supposed" to run a RP on the host. Nextcloud AIO is on the host's own Docker daemon (thus it's running bare-metal), while the reverse proxy is an NGINX instance running on an Ubuntu 22.04 VM (KVM). I'm using the host's IP for the reverse proxy upstream server, which the VM accesses over the virtio network bridge (both VM and host have an IP in the same subnet, I'm using a single NIC). The end result is that basically, the rp and the Docker host are on separate systems.

Cr0iX commented 2 years ago

@szaimen I'm running it on the same vm. Apache reverse proxy on host and nextcloud in docker

Nackophilz commented 2 years ago

Same here

NextCloud AIO is behind Nginx Proxy Manager, all work well instead off Collabora, am unable to connect the app with NextCloud Office config page :/

szaimen commented 2 years ago

Hello, I finally found a way to fix it for Apache! The documentation was redone with https://github.com/nextcloud/all-in-one/pull/1236 and I could verify that it works with Apache now. See https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md#apache. As for nginx or npm, please open a new issue for that. Thanks!

Zoey2936 commented 2 years ago

Maybe change this line?: https://github.com/nextcloud/all-in-one/blob/0bbae775c625e8f42169495cc4b468951b458611/reverse-proxy.md?plain=1#L24

szaimen commented 2 years ago

good idea. will remove the issue from the doc