Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 399401 - www-servers/lighttpd - add more file types to /etc/lighttpd/mime-types.conf
Summary: www-servers/lighttpd - add more file types to /etc/lighttpd/mime-types.conf
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Herb Miller Jr.
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2012-01-19 16:47 UTC by Oschtan
Modified: 2024-03-20 02:05 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
lighttpd-mime.patch (lighttpd-mime.patch,6.49 KB, patch)
2021-02-12 11:29 UTC, Alan Swanson
Details | Diff
lighttpd-mime.patch (lighttpd-mime.patch,8.48 KB, patch)
2021-02-12 15:34 UTC, Alan Swanson
Details | Diff
lighttpd-mime.patch (lighttpd-mime.patch,8.50 KB, patch)
2021-02-12 15:42 UTC, Alan Swanson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oschtan 2012-01-19 16:47:15 UTC
The server does not recognize the video files like "mkv" and "mp4". Required to make these types of self in the /etc/lighttpd/mime-types.conf
I note that the "mp4" is present in /etc/mime.types:
----------------
video/mp4          mp4 mp4v mpg4
---------------
In the case of mkv want to add:
---------------
video/x-matroska        mkv
---------------
In /etc/lighttpd/mime-types.conf need to add both types of files, otherwise they will not play on the client side, as shown as application/octet-stream:
---------------
   ". mkv" => "video/x-matroska",
   ". mp4" => "video/mp4",
........

Reproducible: Always
Comment 1 zlg (RETIRED) gentoo-dev 2016-08-10 09:20:56 UTC
This sounds like something we'll want upstream to support and can patch in the mean time. It'll be on the list for future ebuild versions and I'll send a bug report upstream.
Comment 2 zlg (RETIRED) gentoo-dev 2016-09-12 05:37:50 UTC
Quick update: lighttpd ships a Perl script that will generate a mime-types.conf from the /etc/mime.types file on the host system. Lighttpd itself does not come with a "default MIME types" file, so we should find a way to generate it as needed.

I'll mark this as IN_PROGRESS until I have a suitable solution.
Comment 3 Oschtan 2018-04-22 13:32:29 UTC
".iso"          =>      "application/x-iso9660-image",
".exe"          =>      "application/x-exe"
Comment 4 Alan Swanson 2021-02-12 11:29:20 UTC
Created attachment 686454 [details, diff]
lighttpd-mime.patch

Just switched to lighttpd and after finding cause of almost all files being generic "application/octet-stream" mime type discovered this nine (!) year old bug.

Update with more modern commonly used file types without the bloat from generation from entire using entire /etc/mime.types source. Mildly sorted according to mime type and removed old vim tail.
Comment 5 Alan Swanson 2021-02-12 15:34:25 UTC
Created attachment 686478 [details, diff]
lighttpd-mime.patch

Updated with a few more common mime-types.
Comment 6 Alan Swanson 2021-02-12 15:42:55 UTC
Created attachment 686481 [details, diff]
lighttpd-mime.patch

Missed the docm's "application/" in mime type. Clutz. The lighttpd-angel test passes as usual.
Comment 7 Larry the Git Cow gentoo-dev 2021-02-22 14:47:24 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bd3fc91341d2ef60881ebecce489e68b285426c8

commit bd3fc91341d2ef60881ebecce489e68b285426c8
Author:     Alan Swanson <reiver@improbability.net>
AuthorDate: 2021-02-17 17:56:16 +0000
Commit:     Joonas Niilola <juippis@gentoo.org>
CommitDate: 2021-02-22 14:47:16 +0000

    www-servers/lighttpd: Update mime types, #399401
    
    Update with commonly used file types without the bloat from
    generation using entire /etc/mime.types source.
    
    Closes: https://bugs.gentoo.org/399401
    Signed-off-by: Alan Swanson <reiver@improbability.net>
    Closes: https://github.com/gentoo/gentoo/pull/19507
    Signed-off-by: Joonas Niilola <juippis@gentoo.org>

 www-servers/lighttpd/files/conf/mime-types.conf | 127 ++++++++++++++++++++----
 1 file changed, 109 insertions(+), 18 deletions(-)
Comment 8 gstrauss 2024-03-16 22:23:45 UTC
Alan, how was this list created?  Since lighttpd 1.4.71 (released May 2023) -- a couple years after this bug -- lighttpd provides a builtin default for mimetype.assign if one is not specified in lighttpd.conf.  The builtin defaults contain frequently used mime types for web resources, but not all of the items on the list added here.  The lighttpd builtin mimetype.assign: https://git.lighttpd.net/lighttpd/lighttpd1.4/src/branch/master/src/configfile.c#L947

Should Gentoo lighttpd package use the lighttpd builtin mimetype.assign?  I am open to adding select additional types to the builtin mimetype.assign, though not open to thousands of new types just for funsies or historical curiousity.

Alternatively, the lighttpd release tarball also contains doc/config/conf.d/mime.conf which is generated from mime.types on a Fedora system, and has a much, much larger set of types defined.  The Gentoo lighttpd package could deploy that instead of the custom list you created.
Comment 9 Alan Swanson 2024-03-17 18:02:54 UTC
IIRC I just added what I perceived the most common mime types likely to be seen on the web and sorted the mime types alphabetically so it'd be easier to edit and see missing entries. (I've added a few more locally for weba, avif and jxl but should add step and stl files as quite common for 3D CAD too.)

The lighttpd builtin within src/configfile.c is too limited.

The Fedora derived doc/config/conf.d/mime.conf is maybe too large (though it's only 56Kb text file) and running create-mime.conf.pl during the ebuild on Gentoo would probably create the sameish.

Maintainer choice!
Comment 10 gstrauss 2024-03-18 19:26:51 UTC
Alan, thank you for the response.

>I just added what I perceived the most common mime types likely to be seen on the web

I have no doubt that you have seen these file types served.  Do you perhaps have some other sources to support your assessment of "the most common mime types" ?  I am interested in "common", as in "frequently used by a sizeable percentage of sites".

> The lighttpd builtin within src/configfile.c is too limited.

How so?  For whom?  lighttpd.conf mimetype.assign can be configured by anyone who needs to define additional mime types for use in HTTP response header Content-Type.

As documented in the source code, the list builtin to lighttpd src/configfile.c was collated from
 * lighttpd doc/scripts/create-mime.pl
 * https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
 * https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
 * https://docs.w3cub.com/http/basics_of_http/mime_types
also referencing full /etc/mime.types from
 * http://www.iana.org/assignments/media-types/media-types.xhtml
 * https://salsa.debian.org/debian/media-types/-/blob/master/mime.types
 * https://src.fedoraproject.org/rpms/mailcap/tree/rawhide
 *   https://pagure.io/mailcap/blob/master/f/mime.types

The lighttpd builtin mimetype.assign list is not intended to be a complete list, as you have also noted that the full /etc/mime.types is much, much, much larger.

Your list is more than 2x the entries in the list in lighttpd src/configfile.c.

/etc/mime.types is 27x the entries in the list in lighttpd src/configfile.c

The .rodata binary section in lighttpd is currently 46481 bytes in its entirety in my development branch.  Adding the 100+ entries in your list would add ~4k (a bit under 10% increase) which is measurable.  Adding the full /etc/mime.types would add some 72k (!), which as you also noted, is a very large increase.

---

Anyone who needs a different or larger list of mime types can define their own or use the doc/scripts/create-mime.pl script shipped with lighttpd to generate a large list from /etc/mime.types.

==> Why should the Gentoo basic lighttpd.conf define mimetype.assign instead of using the lighttpd builtin mimetype.assign default?  (or, as some other popular distros do, use create-mime.pl to create a very large list from /etc/mime.types?)

Also, as I posted previously:
>> I am open to adding select additional types to the lighttpd builtin mimetype.assign, though not open to thousands of new types just for funsies or historical curiousity.
Comment 11 Alan Swanson 2024-03-20 01:07:38 UTC
I don't have a statistical study showing the most common mime types on the web hence my "perceived" additions. This saves users on Gentoo all needing to manually add the same missing mime types themselves reducing maintenance burden.

The mime types in src/configfile.c at config_mimetypes_default() can only be described as the bare minimum. So it's a balance between bare minimum and whole shebang (for which 72Kb rodata is nothing).
Comment 12 gstrauss 2024-03-20 02:05:18 UTC
I will try to ask again more directly:

Would you please provide sources for your judgements?

You described the list in src/configfile.c as the bare minimum.  I provided my sources for how that list was compiled and it is intended to be a decent coverage typical web and media types *commonly* used.  You have not provided any source or any statistics or anything other than "feelings" about what you have "perceived" is "most common".  It is difficult to have a constructive debate about your perceived feelings.  By what criteria do you judge "bare minimum"?

If someone is serving files that are not commonly used, they probably do not have a simple website running on bare-bones hardware and so they can configure lighttpd with the whole shebang of mimetype.assign generated from /etc/mime.types without noticing the slight change in memory use.

Should mimetype.assign generated from /etc/mime.types be the default for Gentoo users?  Those on memory constrained systems (where 72k makes a difference) can then tune lighttpd with guidance for small systems.
https://wiki.lighttpd.net/Docs_ResourceTuning
https://wiki.lighttpd.net/Docs_Performance

One more thing: there are some items in your list of "most common" types which are ABSENT from the much, much longer list of /etc/mime.types (checked on a Fedora system).