Page 1 of 2

webdav plugin interoperability with nginx servers

Posted: 2023-09-06, 04:11 UTC
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?

Re: webdav plugin interoperability with nginx servers

Posted: 2023-09-06, 21:16 UTC
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.

Re: webdav plugin interoperability with nginx servers

Posted: 2023-09-06, 22:41 UTC
by scratch monkey
Thanks. :(

Is there a list of (linux) webdav servers known to work properly with TC (on android)?

Re: webdav plugin interoperability with nginx servers

Posted: 2023-09-07, 06:58 UTC
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

Re: webdav plugin interoperability with nginx servers

Posted: 2023-09-07, 16:51 UTC
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...

Re: webdav plugin interoperability with nginx servers

Posted: 2023-09-08, 01:48 UTC
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.

Re: webdav plugin interoperability with nginx servers

Posted: 2023-12-28, 19:42 UTC
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.

Re: webdav plugin interoperability with nginx servers

Posted: 2023-12-29, 09:17 UTC
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.

Re: webdav plugin interoperability with nginx servers

Posted: 2023-12-29, 12:37 UTC
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.

Re: webdav plugin interoperability with nginx servers

Posted: 2024-01-01, 19:53 UTC
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).

Re: webdav plugin interoperability with nginx servers

Posted: 2024-01-02, 10:53 UTC
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

Re: webdav plugin interoperability with nginx servers

Posted: 2024-01-04, 20:31 UTC
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?

Re: webdav plugin interoperability with nginx servers

Posted: 2024-01-05, 09:26 UTC
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

Re: webdav plugin interoperability with nginx servers

Posted: 2024-01-05, 19:34 UTC
by njam
Nice! I can confirm that 370b3 works as expected with Nginx.

Re: webdav plugin interoperability with nginx servers

Posted: 2024-01-08, 09:06 UTC
by ghisler(Author)
Great, thanks! I have sent it to the Play Store for review now.