0

so far I simply use

location /drive/ { # wsgidav 
  proxy_pass http://127.0.0.1:8080/; 
}

and it seems to do the trick. I can put files to the server, get them, browse through directories etc. all from Windows explorer. However, I can not rename a file on the server. When I attempt it, I get 502 Bad Gateway

14:57:44.803 - INFO    : 127.0.0.1 - (anonymous) - [2022-10-14 12:57:44] "MOVE /user/Downloads/Text.txt" dest="https://myserver.com/drive/user/Downloads/Text1.txt", length=0, depth=0, overwrite=F, elap=0.001sec -> 502 Bad Gateway

Am I missing anything in the configuration? Thx

ElFishi
  • 43
  • 1
  • 6

1 Answers1

0

Sry for the noise, found one myself. Will just leave this here in case others find it useful.

There is a closed issue regarding the problem that files can't be renamed behind a reverse proxy. One solution suggested to "Configure the reverse proxy to rewrite the Destination header's protocol from 'https:' to 'http:'".

I followed this suggestion and added a mapping rule outside of the config's server section

map $http_destination $driveDestination { # otherwise MOVE results in a 502 Bad Gateway
    default $http_destination;
    "~*^https://myserver.com/drive/(.+)" /$1;
}

and the following location for the webdav drive

## Begin - wsgidav
location /drive/ { # trailing slash means it will be added
  proxy_pass http://127.0.0.1:8080/; # - trailing slash means location will be dropped

  # https://github.com/mar10/wsgidav/issues/183
  proxy_http_version 1.1;
  proxy_set_header Host $host;
  proxy_buffering off;
  client_max_body_size 0;
  proxy_request_buffering off;

  proxy_set_header Destination $driveDestination; # result of map command above
}

## End - wsgidav

And, alas, it works.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
ElFishi
  • 43
  • 1
  • 6