Range requests broken on CIFS mounted document root
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apache2 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Expected:
Apache2 should be able to serve Range requests for the first byte if it can serve open-ended Range requests for the whole file
Observed:
I upgraded from Ubuntu 18.04 to 20.04. On this server, I have Apache set up to serve video files from a CIFS mount. HTML5 clients are using HTTP Range Requests to obtain random access to the files. A typical request from a desktop looks like:
Range: bytes=0-
And Apache interprets that to mean "give me the whole file starting at byte 0, through the end of the file"
A typical request from a mobile browser however, looks like this:
Range: bytes=0-1
Where the browser wants to grab the first byte (Probably to read some video file meta data at the beginning of the file)
The second type of request, where only the first byte is requested, is failing. If I copy a video from the CIFS mount to the local disk, however, it works just fine. So there seems to be something about grabbing files from the CIFS by byte ranges. The CIFS and mount are using protocol SMBv3.
I've done some Googling and it seems like something regarding EnableSendfile is potentially a problem with remote mounts like CIFS or NFS. However, I can't seem to figure out why this used to work with an older version of cifs-utils and/or apache2 (I'm not sure which is really broken here).
More succinctly, here is the issue demonstrated with curl:
user@server:~$ curl http://
curl: (1) Received HTTP/0.9 when not allowed
user@server:~$ curl http://
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
OS:
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Relevant package info:
apache2:
Installed: 2.4.41-4ubuntu3.1
Candidate: 2.4.41-4ubuntu3.1
Version table:
*** 2.4.41-4ubuntu3.1 500
500 http://
500 http://
100 /var/lib/
2.
500 http://
cifs-utils:
Installed: 2:6.9-1ubuntu0.1
Candidate: 2:6.9-1ubuntu0.1
Version table:
*** 2:6.9-1ubuntu0.1 500
500 http://
100 /var/lib/
2:6.9-1 500
500 http://
Changed in apache2 (Ubuntu): | |
status: | New → Triaged |
Thanks for the report.
I can confirm this behaviour. Here are the reproduction steps, assuming you're in a Focal VM:
# apt install samba apache2 curl cifs-utils test.data bs=1M count=1 0.1/testshare /mnt .*@DocumentRoot /mnt\n\t<Directory /mnt>\n\t\tRequire all granted\ n\t</Directory> ' /etc/apache2/ sites-enabled/ 000-default. conf localhost/ test.data -H 'Range: bytes=0-1'
# cat << EOF >> /etc/samba/smb.conf
[testshare]
path = /testshare
browseable = yes
read only = yes
guest ok = yes
EOF
# mkdir /testshare
# dd if=/dev/random of=/testshare/
# mount -t cifs -o guest //127.0.
# sed -i 's@DocumentRoot
# systemctl restart apache2
# curl http://
curl: (1) Received HTTP/0.9 when not allowed
I marked the bug as Invalid because you can use "EnableMMAP Off" in order to get things working. I agree that this should perhaps be better documented, though.
Can you confirm whether "EnableMMAP Off" works in your case? Also, "EnableSendFile Off" may be needed as well.