abiosoft / caddy-docker

Docker container for Caddy
https://hub.docker.com/r/abiosoft/caddy/
MIT License
768 stars 315 forks source link

Templating breaks mime type of other files (only on this build, not with official Caddy) #182

Closed renaudguerin closed 5 years ago

renaudguerin commented 5 years ago

Enabling templates for .html (or just with default settings) breaks the mime types of JSON files in the paths it is enabled for. They're all served as text/plain; charset=utf-8

Plot twist : I can't reproduce this with Caddy 1.0.0 on my Mac, I only have this problem with this abiosoft/caddy-docker Docker image (so, I don't know if it's a Linux specific problem or due to the way it's built)

Repro steps: very simple Caddyfile with

:2015
templates
mime .json application/json

What I've tried:

Any help greatly appreciated !

renaudguerin commented 5 years ago

I finally have a workaround : the only thing that worked was adding RUN apk --no-cache add mailcap to the Dockerfile. This was probably the only difference between my Linux/Docker environment and the Mac one.

Again, forcing the type with the mime directive was not enough in my case ! Maybe this code path is bypassed when templates is enabled and it falls back to the default case that relies on a mailcap file to determine the type ?

abiosoft commented 5 years ago

I can add mailcap to the docker image if that fixes it.

renaudguerin commented 5 years ago

I still believe this is a bug, but adding mailcap is definitely a workaround !

abiosoft commented 5 years ago

Fixed with https://github.com/abiosoft/caddy-docker/pull/202