Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx webdav could not open collection

Tags:

nginx

webdav

I have built nginx on a freebsd system with the following configuration parameters:

./configure ... –with-http_dav_module

Now this is my configuration file:

user www www;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    # reserve 1MB under the name 'proxied' to track uploads
    upload_progress proxied 1m;

    sendfile        on;
    #tcp_nopush     on;
    client_max_body_size 500m;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    #upload_store /var/tmp/firmware;
    client_body_temp_path /var/tmp/firmware;


    server {
      server_name localhost;
      listen 8080;

      auth_basic "Restricted";
      auth_basic_user_file /root/.htpasswdfile;

      create_full_put_path on;
      client_max_body_size 50m;
      dav_access user:rw group:r all:r;
      dav_methods PUT DELETE MKCOL COPY MOVE;
      autoindex on;
      root /root;

      location / {
      }
    }
}

Now, the next things I do are check the syntax of the confiuration file by issuing a nginx -t and then do a graceful reload as follows: nginx -s reload.

Now, when I point my web-browser to the nginx-ip-address:8080 i get the list of my files and folders and so on and so forth (I think that is due to the autoindex on feature).

But the problem is that when I try to test the webdav using cadaver as follows:

cadaver http://nginx-ip-address:8080/

It asks me to enter authorization credentials and then after I enter that it gives me the following error:

Could not open Collection: 405 Not Allowed

And the following is the nginx-error-log line which occurs at the same time:

*125 no user/password was provided for basic authentication, client: 172.16.255.1, server: localhost, request: "OPTIONS / HTTP/1.1", host: "172.16.255.129:8080"

The username and pass work just fine wheni try to access it from the web-browser, then what is happening here?

like image 843
surajravi Avatar asked Jul 10 '14 02:07

surajravi


1 Answers

It turns out that the webdav module in-built in nginx is broken and to enable full webdav, we need to add the following external 3rd party module: nginx-dav-ext-module.

Link to its github: https://github.com/arut/nginx-dav-ext-module.git

The configure parameter would now be:

./configure --with-http_dav_module --add-module=/path/to/the/above/module

The built in one just provides the PUT DELETE MKCOL COPY MOVE dav methods.

The nginx-dav-ext-module adds the following additional dav methods: PROPFIND OPTIONS

You will also need to edit the configuration file to add the following line:

dav_ext_methods PROPFIND OPTIONS;

After doing so check if the syntax of the conf file is intact by issuing: nginx -t

and then soft reload (gracefully) nginx: nginx -s reload

And Voila! you should now be able to use cadaver or any other dav client program to get into the directories.

I cannot believe that I solved this, it drove me nuts for a while!

like image 188
surajravi Avatar answered Nov 14 '22 23:11

surajravi