Wrong download link on link shared mp4 files

Nextcloud version : 24.0.8
Operating system and version: Debian 5.10.158-2
nginx version : 1.23.1
PHP version: PHP 8.1.14

We have got a problem with the download link of a shared mp4 file. If we share an mp4 file per link the download button leads to an address …/download/video.mp4 where we get an 404 error. If we remove /video.mp4 from the link under …/download the video can be downloaded.
If we rename the file to video.mkv in the nextcloud the download button is working as expected.

Steps to replicate it:

  1. Upload a video.mp4 file
  2. Create a link share
  3. Open link and press “Download”

On reddit someone describes the same problem:
https://www.reddit.com/r/NextCloud/comments/vjzx6d/shared_file_download_button_does_not_work/

Sorry i have got not the problem. I think it is a link problem.

e.g.
https://cloud.server.tld/s/rJfBmFcqdwcmT9K/download/test.mp4
vs.
https://cloud.server.tld/s/rJfBmFcqdwcmT9K/download

Maybe the error is caused by a wrong rewrite rule of nginx. Maybe you can search in this direction.

Thanks for your hint. I think the problem occures because of this part of the ngnix.conf:

location ~ \.(?:flv|mp4|mov|m4a)$ {
		mp4;
		mp4_buffer_size 100M;
		mp4_max_buffer_size 1024M;
		fastcgi_split_path_info ^(.+?.php)(\/.*|)$;
		set $path_info $fastcgi_path_info;
		try_files $fastcgi_script_name =404;
		include fastcgi_params;
		include php_optimization.conf;
		}

We added this because we have trouble playing video files in the nextcloud.

After removing this block the download works but again leads to problems playing the video file.

I’m not an expert for this configuration. Has anybody an advice how to change this so that both, downloading and playing, works?

Thanks
Peter