webdav plugin interoperability with nginx servers

Support for Android version of Total Commander

Moderators: white, Hacker, petermad, Stefan2

User avatar
scratch monkey
Junior Member
Junior Member
Posts: 3
Joined: 2023-09-05, 09:23 UTC

webdav plugin interoperability with nginx servers

Post by *scratch monkey »

It appears that the TC webdav plugin doesn't entirely follow the protocol specifications.

Looking at my server logs, it seems the cause is that in some situations, the plugin does not append `/` appropriately to collection names when it SHOULD do so.

Code: Select all

600 MKCOL can create a collection only, [...], request: "MKCOL /webdav/test HTTP/2.0"
758 "/webdav/test" is collection, [...], request: "MOVE /webdav/test HTTP/1.1"
1055 both URI "/webdave/old/" and "Destination" URI "https://www.example.org/webdav/new" should be either collections or non-collections, [...], request: "MOVE /webdav/old HTTP/1.1"
Although I was finally able to configure nginx so that I can use the GUI to select a folder and copy or move it around the webserver, I cannot long-press to rename, nor can I create new collections using ... > New Folder

The nginx developers appear to refuse to support this. See for example:
* https://trac.nginx.org/nginx/ticket/1966
* https://trac.nginx.org/nginx/ticket/604

I tried the nginx configuraion suggestions at https://www.robpeck.com/2020/06/making-webdav-actually-work-on-nginx/ but could not make everything work (the nginx "if" command is very nonintuitive and I don't understand it).

Are there any plans to correct the plugin behaviour?

Until then, does anyone know of a config for nginx to allow full functionality?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

Unfortunately I have had varying results - some servers seem to expect a trailing slash for folders, some do not work with trailing slashes.
Author of Total Commander
https://www.ghisler.com
User avatar
scratch monkey
Junior Member
Junior Member
Posts: 3
Joined: 2023-09-05, 09:23 UTC

Re: webdav plugin interoperability with nginx servers

Post by *scratch monkey »

Thanks. :(

Is there a list of (linux) webdav servers known to work properly with TC (on android)?
JOUBE
Power Member
Power Member
Posts: 1477
Joined: 2004-07-08, 08:58 UTC

Re: webdav plugin interoperability with nginx servers

Post by *JOUBE »

ghisler(Author) wrote: 2023-09-06, 21:16 UTC Unfortunately I have had varying results - some servers seem to expect a trailing slash for folders, some do not work with trailing slashes.
2ghisler(author)
With nginx, the problem does not seem to be completely or relatively difficult to solve even with configurations (https://www.robpeck.com/2020/06/making-webdav-actually-work-on-nginx/). Would it be possible to make the trailing slash configurable? Maybe ask for a {{/}} or {/} somewhere in one of the configuration lines of the plugin (and - of course - then remove it during the run) or even in the connection name line: connectionname1{/} or connectionname1[/] or whatever. Which signals the plugin to append the trailing slash.

Joube
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

The Windows version has it as an option. The Android version was mainly relying on redirects to detect when a slash is needed and when it isn't. So far regular WebDAV servers like Apache with WebDAV extensions (even through Nginx) have worked fine. I didn't know that Ngnix supports WebDAV too...
Author of Total Commander
https://www.ghisler.com
User avatar
scratch monkey
Junior Member
Junior Member
Posts: 3
Joined: 2023-09-05, 09:23 UTC

Re: webdav plugin interoperability with nginx servers

Post by *scratch monkey »

Thanks for the information. If I start using WebDAV more seriously, I may well try Apache.
If I hadn't already been using nginx, it would have been my first choice to investigate.

I tried "dave" but that also had problems.
"SFTPGo" is popular but looks too heavyweight for my purposes.

Currently I have "dufs" running behind nginx proxy.
From my limited testing it works well, although the author's anonymity concerns me.
njam
Junior Member
Junior Member
Posts: 6
Joined: 2023-12-26, 20:14 UTC

Re: webdav plugin interoperability with nginx servers

Post by *njam »

I'm trying to connect to an Apache WebDAV directory using TC-Android, and I think there's a similar problem.

I'm unable to rename directories, but I can rename files.
I couldn't unearth any error from Apache logs yet though.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

Well, the documentation says:
"In general clients SHOULD use the "/" form of collection names."
It doesn't say MUST. The problem is that some servers don't seem to like the / at the end.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

Please try this beta version:
https://www.totalcommander.ch/android/tcandroidwebdav370b1.apk

It should work both with Apache (rename) and NGINX (create and rename).
The problem with Apache was that it sent a 301 error (different location) but both the OKhttp client and the Apache client sent the wrong redirected request. I'm now handling the redirect manually, which seems to work fine.
Author of Total Commander
https://www.ghisler.com
njam
Junior Member
Junior Member
Posts: 6
Joined: 2023-12-26, 20:14 UTC

Re: webdav plugin interoperability with nginx servers

Post by *njam »

@ghisler nice, thanks!

- Tested with Nginx: create and rename folder works.
- Tested with Apache: create and rename folder works

I can see that the application is now just trying both options (first without slash, and if it fails with slash). Nice solution. And thanks for looking into it!

(btw to install the plugin APK on Android I had to uninstall the plugin first, then install the APK. Just "upgrading" wouldn't use the plugin in TC).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

Thanks for your feedback! It's odd that you had to uninstall it, it uses the same signature as the Play Store version and shouldn't need that.
I can see that the application is now just trying both options (first without slash, and if it fails with slash).
In beta 2, I have optimized this a bit now: If renaming without slash fails, but works with slash, the plugin will then always append a slash during that session. Same for creating directories (stored separately). Here is the updated beta:
https://www.totalcommander.ch/android/tcandroidwebdav370b2.apk
Author of Total Commander
https://www.ghisler.com
njam
Junior Member
Junior Member
Posts: 6
Joined: 2023-12-26, 20:14 UTC

Re: webdav plugin interoperability with nginx servers

Post by *njam »

With 370b2 the first renaming of a folder works fine, but a second renaming of a folder fails.

Error from nginx:
2024/01/04 20:27:55 [error] 13643#13643: *21919 both URI "/dav/njam-home/d6/" and "Destination" URI "https://example.com/dav/njam-home/d7" should be either collections or non-collections, client: 2a02:169:5ab:0:a531:3109:5adc:aa2b, server: example.com, request: "MOVE /dav/njam-home/d6/ HTTP/1.1", host: "example.com"
Probably the destination path is not properly adjusted, and should also have a slash appended?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

You are right, thanks for reporting it! By mistake I only tested the plugin with the Apache WebDAV server.
Please test beta 3:
https://www.totalcommander.ch/android/tcandroidwebdav370b3.apk
Author of Total Commander
https://www.ghisler.com
njam
Junior Member
Junior Member
Posts: 6
Joined: 2023-12-26, 20:14 UTC

Re: webdav plugin interoperability with nginx servers

Post by *njam »

Nice! I can confirm that 370b3 works as expected with Nginx.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: webdav plugin interoperability with nginx servers

Post by *ghisler(Author) »

Great, thanks! I have sent it to the Play Store for review now.
Author of Total Commander
https://www.ghisler.com
Post Reply