Nixtren
(Nixtren)
#1
Example scenario:
- Static website (index.html and about.html)
Example Caddyfile:
127.0.0.1:8000 {
root .
templates / .html
rewrite {
if {file} not favicon.ico
to {path} {path}/ {path}.html
}
}
Example links:
http://127.0.0.1:8000/
http://127.0.0.1:8000/index
http://127.0.0.1:8000/about
What happens:
Plain HTML source-code appears (i.e. MIME type text/plain), instead of rendering it.
Removing the following line from Caddyfile makes HTML to render correctly:
templates / .html
Is it a bug?
Edit 1: I removed the rewrite directive, the problem persists.
Out of curiosity, what happens when you access http://127.0.0.1:8000/index.html
?
What about with just templates
(as opposted to templates / .html
)?
Nixtren
(Nixtren)
#3
MIME text/plain
Same effect
127.0.0.1:8000 {
root .
templates
}
Bug report created: https://github.com/mholt/caddy/issues/1417
1 Like
Whitestrake
(Matthew Fay)
#4
In the meantime, as a workaround, are you able to set the content type manually with the mime directive?
1 Like
Nixtren
(Nixtren)
#5
I tried with the MIME directive, it partially worked (IIRC it worked with /index and /about, but not /).
Curiously, I’ve been able to fix this MIME issue by running dos2unix on the HTML files 
1 Like
Whitestrake
(Matthew Fay)
#6
Wait, Caddy thought the html files were text/plain because of line endings…? Interesting to note.
system
(system)
closed
#7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.