xnaas
(DELETE ME)
February 1, 2022, 11:52pm
1
I’ve looked at templates (Caddyfile directive) — Caddy Documentation , but don’t understand how to override a sent/configured mime type.
In particular, I want to have FLAC files sent as audio/flac
not audio/x-flac
as the latter is actually non-standard, according to Mozilla (and it breaks FLAC embeds in The Lounge to send the latter ).
Note: I use Caddyfile, not JSON.
In nginx you just use something like server-configs-nginx/mime.types at main · h5bp/server-configs-nginx · GitHub to accomplish the goal.
How would I accomplish this with Caddy/Caddyfile?
1 Like
xnaas
(DELETE ME)
February 2, 2022, 12:42am
2
I was reviewing some code to see if there was anything I could submit a PR for, perhaps, but I don’t really know what I’m looking at. Don’t know that a PR would be accepted to make the FLAC mime type match MDN, but… ¯\_(ツ)_/¯
These appear to be all the files that reference mime
in any way.
1 Like
See this issue, where someone asked the same question:
opened 12:53PM - 24 Jan 22 UTC
closed 07:04PM - 24 Jan 22 UTC
declined
plugin
This is question and suggestion. Is there any way to implement this AddType rule… originally seen in apache called mime_mod? If not, is there any suggestion to implement this as an extension to Caddy? (some guide on how to do it correctly. I know that there is an API in GO to create modules).
What exactly I need is to implement the following rule: "AddType application/x-httpd-php .html"
1 Like
xnaas
(DELETE ME)
February 2, 2022, 2:09pm
4
Dang, can’t believe I missed that one searching GitHub. Bleh.
That basically sets the Content-Type header, right?
So wouldn’t you just need:
@html path *.html
header @html Content-Type application/x-httpd-php
Or something like that?
This solution from Matt does seem to work nice for one-offs. Would seem a bit extreme to use this method to define many things.
Go pulls the mime types from your system’s mailcap
file locations, see if you can add any mappings in there. Quick google search brought me to Ubuntu Manpage: update-mime - create or update MIME information , which may be relevant depending on your OS.
I don’t think this is something we’d need in Caddy’s core, you could possibly write a plugin to add overrides using the mime package - mime - Go Packages stdlib package. You can find the docs for Caddy plugins here: Extending Caddy — Caddy Documentation
I took a look at mime package - mime - Go Packages as well and see that you can indeed map a mime.types
file a la nginx, but the formatting appears to be different and picky, so I’ll have to adjust my current file to make golang’s mime
library happy, I guess. At least I’ll only have to do it once…
1 Like
system
(system)
Closed
March 3, 2022, 11:52pm
6
This topic was automatically closed after 30 days. New replies are no longer allowed.