Closed vay3t closed 2 years ago
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?
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 http://manpages.ubuntu.com/manpages/bionic/man8/update-mime.8.html, 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 https://pkg.go.dev/mime stdlib package. You can find the docs for Caddy plugins here: https://caddyserver.com/docs/extending-caddy
In case any one is interested in using their own mime.types file with Caddy, I've uploaded https://github.com/xnaas/webserver/blob/master/caddy/mime.types. Per the comments, the file is based on https://github.com/h5bp/server-configs-nginx/blob/a9617688fc921e728d5dcd044db9327aa50ede79/mime.types, I've just modified it to make the golang mime library happy.
Just running into this issue again but given the work around
@html path *.html
header @html Content-Type application/x-httpd-php
where do I add this in a file server ? Does the path go elsewhere in the file, as this does not seem to do the trick and instead is returning content type text/html
handle_path /media/* {
@png path *.png
header @png Content-Type image/png
root * /home/<redacted>/media/
file_server
}
@ghostwheel42 I'd love to see how your list is implemented in a caddy file!
@eddyizm What is complete output (and the command) of a curl -v
request that gives back HTML instead of PNG?
@mholt I tried a slew of things and gave up. I believe this is not an issue with caddy but an issue with my django application/template. Thanks for the reply!
Ok. Thanks for letting us know!
No problem, trying to work out all my issues, hoping to switch all my servers to Caddy, it's really amazing!
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"