Comment 3 for bug 2003709

Revision history for this message
Bryce Harrington (bryce) wrote :

Debian appears to provide its own magic file (debian/config-dir/magic), which has been shipped since 2.2.12-1, and gets installed to /etc/apache2/magic. That release includes this changelog entry about it:

      * Ship our own version of the magic config file (taken from file 4.17-5etch3)
        which is still compatible with mod_mime_magic (closes: #483111).

apache2.README.Debian mentions it:

   magic
        Patterns for mod_mime_magic. This is not compatible with the format
        used by current versions of the file/libmagic packages.

LP: #601501 is a wishlist bug to switch to using shared-mime-info. mime-info is different from mime-magic, however the bug includes this comment relating to magic:

    Apache's mod_mime_magic does not support all features that are used in /usr/share/mime/magic. Using that file would result in error messages. And from a quick glance at libmagic, it doesn't seem possible to use it in mod_mime_magic either because it is not thread safe. Therefore apache brings its own magic file.

So, sounds like it's kind of expected that file would be broken, but presumably the broken content-type is a legit bug. Although since the file has apparently been there since Apache 2.2, it seems weird this would crop up as a problem now. Did this use to work for you pre-jammy? Testing on bionic, I don't see a content-type listed there either.

    $ curl -i http://10.69.244.198/foo | less
      % Total % Received % Xferd Average Speed Time Time Time Current
                                     Dload Upload Total Spent Left Speed
    100 33 100 33 0 0 28896 0 --:--:-- --:--:-- --:--:-- 33000
    HTTP/1.1 200 OK
    Date: Wed, 08 Feb 2023 03:32:54 GMT
    Server: Apache/2.4.29 (Ubuntu)
    Last-Modified: Wed, 08 Feb 2023 03:31:42 GMT
    ETag: "21-5f427e7279e93"
    Accept-Ranges: bytes
    Content-Length: 33

    <!DOCTYPE HTML>
    blah blah bionic

It seems the same regardless of whether module mime_magic is enabled

    # a2enmod mime_magic
    # systemctl restart apache2
    # apache2ctl -M | grep magic
     mime_magic_module (shared)
    # curl -i http://10.69.244.198/foo | less

Can you explain in more detail how you got apache2 to include the content-type header from the magic config info, for extensionless files?

I can get content-type to detect based on extension, e.g. index.html and such, but getting it to work via magic I'm not reproducing.