Range requests broken on CIFS mounted document root

Bug #1916391 reported by Alex Hutnik
10
This bug affects 1 person
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://localhost/videos/test_file.mp4 -H 'Range: bytes=0-1'
curl: (1) Received HTTP/0.9 when not allowed

user@server:~$ curl http://localhost/videos/test_file.mp4 -H 'Range: bytes=0-'
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://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.4.41-4ubuntu3 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
cifs-utils:
  Installed: 2:6.9-1ubuntu0.1
  Candidate: 2:6.9-1ubuntu0.1
  Version table:
 *** 2:6.9-1ubuntu0.1 500
        500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2:6.9-1 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages

Changed in apache2 (Ubuntu):
status: New → Triaged
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

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
# 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/test.data bs=1M count=1
# mount -t cifs -o guest //127.0.0.1/testshare /mnt
# sed -i 's@DocumentRoot.*@DocumentRoot /mnt\n\t<Directory /mnt>\n\t\tRequire all granted\n\t</Directory>' /etc/apache2/sites-enabled/000-default.conf
# systemctl restart apache2
# curl http://localhost/test.data -H 'Range: bytes=0-1'
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.

Changed in apache2 (Ubuntu):
status: Triaged → Invalid
Revision history for this message
Alex Hutnik (alex-hutnik) wrote :

I can confirm this worked. I added "EnableMMAP Off" to apache2.conf and restarted the service with "service apache2 restart"

For what it's worth, I did not need to add any entries for EnableSendfile.

Thank you very much for your assistance.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.