Greetings
I am running Nextcloud 15.0.4.0 from the official Docker container, behind a reverse nginx proxy with the following configuration:
server {
listen 443 ssl http2;
server_name cloud.example.net;
location / {
proxy_pass http://cloud:80;
}
}
When I access WebDAV over davs://cloud.example.net:443/remote.php/dav/files/<USERNAME>/
, everything works as expected. However, to simplify the URL, I decided to create a new subdomain dav.example.net
, which would point to cloud.example.net/remote.php/dav/files/
, so that I can simply write davs://dav.example.net/<USERNAME>
to access my files. I tried the following nginx configuration:
server {
listen 443 ssl http2;
server_name dav.example.net;
location / {
proxy_pass http://cloud:80/remote.php/dav/files/;
}
}
or
server {
listen 443 ssl http2;
server_name dav.example.net;
location / {
rewrite ^/(.+)$ /remote.php/dav/files/$1 break;
proxy_pass http://cloud:80/;
}
}
This sort of works, as I can access, edit, and delete files, but I get 403 when I try to rename files:
pmg@exa:~/cloud$ mv abc.txt abc2.txt
mv: cannot move 'abc.txt' to 'abc.txt': No such file or directory
The server emits this log:
172.26.0.6 - pmg [20/Feb/2019:13:36:51 +0000] "MOVE /remote.php/dav/files/pmg/abc.txt HTTP/1.0" 403 1541 "-" "-"
Additionally, fusedav records the following call:
rename(/pmg/abc.txt, /pmg/abc2.txt)
CGET: /pmg/abc.txt
STAT-CACHE-MISS
CSET: /remote.php/dav/files/pmg/abc.txt
MOVE failed: 403 Forbidden
When I use the long URL, everything works fine:
pmg@exa:~/cloud$ mv abc.txt abc2.txt
pmg@exa:~/cloud$
172.26.0.6 - pmg [20/Feb/2019:13:42:49 +0000] "MOVE /remote.php/dav/files/pmg/abc.txt HTTP/1.0" 201 1389 "-" "-"
rename(/remote.php/dav/files/pmg/abc.txt, /remote.php/dav/files/pmg/abc2.txt)
CGET: /remote.php/dav/files/pmg/abc.txt
I can see that the problem is how WebDAV issues the rename command (rename(/pmg/abc.txt, /pmg/abc2.txt)
vs. rename(/remote.php/dav/files/pmg/abc.txt, /remote.php/dav/files/pmg/abc2.txt)
). Specifically, the target needs to have the /remote.php/dav/files/
prepended, but this part isn’t rewritten by nginx.
I can manually call rename(/pmg/abc.txt, /remote.php/dav/files/pmg/abc2.txt)
which works, but requires a non-standard WebDAV client.
Any ideas how to force nginx to modify the MOVE commands, or how to convince NextCloud to accept these abbreviated paths?
Thanks