Nextcloud take 2

Posted on Fri 04 November 2022 in System

After some months (and tanks to some random people on Internet), I decided to give Nextcloud another chance... Well, not really.

Back in February, I got sick of the problems I had upgrading Nextcloud which nearly destroyed my server. A server that as also some public sites I am running.

After dropping Nextcloud, I still had the problem of synchronize the files on 3 PC (2 Linux and 1 windows) and a phone, so I tried out Syncthing. It was a good enough solution but I found it miss something, expecially in the configuration aspect. Maybe I set up it wrong, but I had to duplicate a bunch of locations to make it work.

Anyway, talking to someone, I got the suggestion to use Nextcloud in a Docker container that should make it easy to integrate in a system with other complex software. Fine, let's try it.

Good point: the installation were smooth enough. Even with the basic image and commands, Nextcloud was up and running in no time.
Bad point: the default image is bugged. It work well with a browser, but if you want a desktop client, it does not work.

The error The error you get, aside a warning in the web browser, while trying to login with a Desktop client (or mobile app) is:

The polling URL does not start with HTTPS despite the login URL started with HTTPS. Login will not be possible because this might be a security issue. Please contact your administrator.

which is what ?

After some digging, I found out that the cause is a missing option in the config.php file, more precisely (at lease in my case)

'overwriteprotocol' => 'https',

Ok, simple enough to fix... or that is what I was thinking... I was wrong by a long shot.

The problem Simple, my Nextcloud was running inside a docker container and I am no expert in Docker. So, while I know it is possible, I have no idea how to change the docker-compose rules to either

  • allow to extract a file to the host machine
  • include the option in the build process

The solution After some failed attempts, I solved this in the least optimal solution but hey, it worked.

This is the set of commands I used. With

docker ps -a

I got the id of the container, then with

docker exec 9cf084d19db4 sh -c "head -46 config/config.php > config/test.php"
docker exec 9cf084d19db4 sh -c "echo \'overwriteprotocol\' =\> \'https\', >> config/test.php"
docker exec bb241e2e020b sh -c "echo \)\; >> config/test.php"
docker exec bb241e2e020b sh -c "cat config/test.php"
docker exec bb241e2e020b sh -c "cp config/config.php config/config.php.orig"
docker exec bb241e2e020b sh -c "cp config/test.php config/config.php "

I added the line to the a copy of the file and finally

docker-compose stop && docker-compose up -d

to restart the container without building it.

In the end it worked and I am now able to login with the desktop clients and mobile app.