dimanche 5 août 2018

NGINX make directory readonly unless authentication provided

I have a directory public, where I will upload various files. I want those files to be downloadable without any authentication. However, I also want to be able to edit and add new files using WebDAV, if authentication is provided. Is there any way I can have both behaviors on the same directory (location)?

I tried the following hack:

    location /public/ {
        if ($remote_user != "") {
            return 302 e;
        }
        auth_basic off;
        fancyindex off;
        dav_methods off;
    }

    location /public/e {
    }

However, I could not find a way to make /public/e index /public/ instead.

I also thought about making two directories, public and public-webdav, which are symlinked to the same directory, and assign different nginx locations to them, but I was hoping for a cleaner solution.

Thanks!




Aucun commentaire:

Enregistrer un commentaire