502 Bad Gateway error on WebDav when syncing or renaming files

The solution i came accross is to rewrite the destination url.

Without rewriting, the MOVE command passes the whole url which somehow doesn’t work with wsgidav:

"MOVE /Fotos/DCIM/Camera/IMG_20230312_190344.jpg~ttxpart~" dest="https://custom.domain.de:9000/seafdav/Fotos/DCIM/Camera/IMG_20230312_190344.jpg", length=0, depth=0, overwrite=T, elap=0.029sec -> 502 Bad Gateway

With the solution you remove the destination host part in the url all together by using a relative url instead of absolute:

"MOVE /Fotos/DCIM/Camera/IMG_20230312_190344.jpg~ttxpart~" dest="/seafdav/Fotos/DCIM/Camera/IMG_20230312_190344.jpg", length=0, depth=0, overwrite=T, elap=0.721sec -> 204 No Content

As i can’t include links (for whatever reason, even to the forum…), the solution for a nginx reverse proxy is this (which came from the user hambier):

# in the "location /seafdav" block:
set $destination $http_destination;
if ($destination ~* ^https?://[^/]+(/seafdav/.+)$) {
		set $destination $1;
}
proxy_set_header Destination $destination;

This should be possible with apache too.

Edit:
My whole /seafdav part in the nginx confs looks like this:

location /seafdav {
	proxy_pass         http://127.0.0.1:8080/seafdav;
	proxy_set_header   Host $host;
	proxy_set_header   X-Real-IP $remote_addr;
	proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header   X-Forwarded-Host $server_name;
	proxy_set_header   X-Forwarded-Proto $scheme;
	proxy_read_timeout  1200s;
	proxy_request_buffering off;
	client_max_body_size 0;

	set $destination $http_destination;
	if ($destination ~* ^https?://[^/]+(/seafdav/.+)$) {
			set $destination $1;
	}
	proxy_set_header Destination $destination;

	access_log      /var/log/nginx/seafdav.access.log seafileformat;
	error_log       /var/log/nginx/seafdav.error.log;
}