mickstar / Zoo-For-Zotero

This is an Android app for viewing Zotero libraries.
562 stars 53 forks source link

WebDav error "Error contacting … (401 Authorization Required) #169

Open adno opened 2 years ago

adno commented 2 years ago

When I try to set up webDAV, I get this:

Error connecting to webDAV server Error setting up webdav, message: com.thegrizzlylabs.sardineandroid.impl.SardineException: Error contacting http://[domain]/zotero (401 Authorization Required)

Details:

  1. My server requires HTTPS and redirects HTTP requests to HTTPS (which I think is the norm nowadays).

  2. I have specified address as https://[domain]/zotero (https) but the error message contains just http. This is really weird.

  3. I have set up "Basic" authentication on my server, so this should not be an issue. It returns the WWW-Authenticate: Basic realm="Password" header and the following command works just fine and creates a directory on the server using a webDAV command:

    curl --basic -X MKCOL http://[user]:[pass]@[domain]/zotero/newtestdirectory

  4. As one would expect, if you access my server's address (whether HTTP or HTTPS) without login/password it returns "401 Authorization Required"

  5. My server works just fine in Zotero for Mac and iPhone.

labilezhu commented 1 year ago

I have a similar problem. It seems that is because the HTTP server behind HTTPS reverse proxy response an HTTP Redirect to "http://xyz". Because the App use "https://xyz/zotero" but the HTTP server redirects it to "http://xyz/zotero/". If it is an Apache HTTP server, you can use: "DirectorySlash Off". e.g:

        <Directory /var/www/html/webdav>
            DAV On
...
            DirectorySlash Off    
        </Directory>   
luetyk commented 1 year ago

Hi @labilezhu , do you maybe have an idea, how one can obtain the same effect with nginx reverse proxy? I've been faced with the same error, on my private webdav server, but with a nginx in between.

labilezhu commented 1 year ago

Hi @labilezhu , do you maybe have an idea, how one can obtain the same effect with nginx reverse proxy? I've been faced with the same error, on my private webdav server, but with a nginx in between.

Actually, my stack is Nginx as SSL terminator and Apache as WebDav server. My issue is the redirection from Apache. I do not use Nginx as a WebDav server. In my case, Nginx do not know a URL is a directory or not. So I can only update the configuration of Apache.

If you do want to try it in Nginx, may be the 'rewrite' can help. Just FYI, I have not try it: https://ubiq.co/tech-blog/remove-trailing-slash-in-nginx/

luetyk commented 1 year ago

Oh, now I see, previously I misunderstood your configuration. Your proposed solution for nginx ends with an infinitive-loop error. So I had to change my webdav server.

If anybody meets a similar problem, I've noted that bytemark/webdav with forced https on the reversed-proxy does not work properly with the Zoo, whereas drakkan/sftpgo works fine.