M
M
MistikFox2020-05-24 14:08:56
linux
MistikFox, 2020-05-24 14:08:56

How to separate Nginx permissions to WebDav user directories?

Good afternoon. I have a task - to develop WebDaV user management with Nginx web server. I set up nginx to work with webdav, checked the performance, everything is fine. Then it was necessary that each user who logs in through the htpasswd file be created in a separate directory in the `srv/webdav` directory. That is, you need the user `user` to enter the command `curl --user 'user:123' -T /home/user/Desktop/file.txt ' localhost/webdav/file.txt', and its file was moved from the desktop to the `srv/webdav/user/` directory. But there is a problem that any user authorized through the web server can work with files of another user. I tried to manually create a directory with a username and give the user privileges to use the directory via the commands `chown user /srv/webdav/user` and 'chmod 700 user /srv/webdav/user', but after only one user of course and will have access to this directory, and if you try to execute the curl command, then nginx simply does not have permission to write the file, even though the command is executed on behalf of the user. Please tell me how to make these restrictions.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Karpion, 2020-05-24
@Karpion

If " the user who is authorized through the htpasswd file " - this means that he is not authorized in the system. So, file permissions (chown, chmod, that's all) will not help you.
I didn't understand what "user" means in your commands. Is it a specific username?
If " each user is authorized through the htpasswd file - it is created in a separate directory in the `srv/webdav` directory ", then in this directory you need to create a .htpasswd file and set access rights for users in it - but not system ones, but which are " authorized through the htpasswd file ".
I hope I have explained clearly.

O
Official account of the Timeweb team, 2020-05-27
@timeweb_team

As we understand, the end goal is to set up an authorization in nginx, which takes passwords from different user directories and checks their authenticity depending on the authorization.
Try to read the manuals:
https://hamsterden.ru/nginx-password-htaccess/
https://blog.listratenkov.com/kak-nastroit-bazovuj...
https://www.8host.com/blog/nastrojka -avtorizacii-n...
It may be useful to set up different user rights:
https://interface31.ru/forum/index.php?topic=230.0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question