sixem / ivfi-php

IVFi is a directory indexer that aims to make it easy to browse and explore web-accessible directories.
https://git.five.sh/ivfi/
Other
103 stars 18 forks source link

WebDAV Compatability #12

Closed soarn closed 4 years ago

soarn commented 4 years ago

Context: @2003cah and I both share a VPS, they setup WebDAV for a note application (Joplin) that they use in order to keep encrypted backups of the notes stored on the VPS.

Directory listing content is served from: /var/www/html/

The problem as explained by them:

If webdav is placed outside the [/var/www/]html folder, we get a 500 because it's an invalid path to the indexer, if it's placed in the [/var/www/]html folder, it sends a wacky XML response(?) that messes with both Joplin and all my webdav clients

Here's the error that Joplin puts out if the indexer is in the /var/www/html/ folder: image

My best guess is that WebDAV doesn't like the indexer trying to change stuff in that folder, which brings up the question: "Is it possible to disable the indexer on certain directories?"


After discussing it more, I've got:

If the webdav folder is in /var/www/ and Apache is configured to serve the site via direct linking only (no showing it under the default apache directory listings) and without the eyy-indexer in the /var/www/html then webdav works.

If the webdav folder is in the /var/www/html/ folder and Apache is configured to serve the site via direct linking only (no showing it under the default apache directory listings) and with the eyy-indexer in the /var/ww/html/ folder then webdav works in the sense that the folder is not shown and is properly password protected, but the webdav folder is unable to be properly utilized by Joplin (or any webdav client) and results in this error:image

sixem commented 4 years ago

I have to say that this is a little bit confusing as i've never used any of these programs, but to me it looks like Joplin is trying to access or fetch a response from a URL where the indexer is active? It expects some XML data but all it gets it the HTML of the indexer. This would make sense if it is resolved once the indexer is out of /var/www/html/ as by default it will be applied to every valid path without any of the default indexes present.

The indexer doesn't change anything in the folder, all it does is read the server's REQUEST_URI and then reads file attributes etc and displays the data.

Honestly, i'm not sure what i could do to fix this unless i'm missing something. I think you would have to find a way to configure Apache to only serve the indexer under certain conditions so that it doesn't interfere with Joplin/WebDAV.

soarn commented 4 years ago

Alrighty, I'll start looking into it more, thanks for the step in the right direction.

sixem commented 4 years ago

I was thinking a little bit.. i'm guessing you are using the default setup?

Instead of using it globally like this:

DirectoryIndex index.php index.html /indexer.php

You can instead enable it for certain directories, like so:

<DirectoryMatch "^/var/www/html/(enabledforthis|andforthisfolder)/?(?:/(.*))$">
        DirectoryIndex index.php index.html /indexer.php
</DirectoryMatch>

DirectoryMatch uses regex and can be easily customized.

And for example to disable it for the document root but keep it enabled for all sub-directories:

<Directory "/var/www/html/*/">
        DirectoryIndex index.php index.html /indexer.php
</Directory>

<Directory "/var/www/html/">
        DirectoryIndex index.php index.html
</Directory>

Edit:

I just noticed that the error message says Index of /webdav/ which means that it's attempting to access /var/www/html/webdav/, so maybe something like this would work:

DirectoryIndex index.php index.html index.htm /indexer.php

<DirectoryMatch "^/var/www/html/webdav/?(?:/(.*))$">
        DirectoryIndex index.php index.html
</DirectoryMatch>
soarn commented 4 years ago

Sadly this didn't seem to work, so I'm going to try some more methods throughout the week and try to get this working, or I'll convince Cah to just use SFTP and not WebDAV

soarn commented 4 years ago

@2003cah Figured it out! In the Apache .conf file for the directory, there was a directive that turned off PHP.

Simple as that I guess.

But thank you for your help and suggestions!