Resource interpreted as Stylesheet but transferred with MIME type text/plain

Hi there :slight_smile:

since I upgraded to Caddy 2 today, my stylesheets, of the kuhnweblab.com directive, are interpreted as text/plain. Anyone knows this problem?

1. Caddy version (caddy version):

v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=

2. How I run Caddy:

Via systemd

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target

[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

a. System environment:

Ubuntu 18.04.4 LTS

d. My complete Caddyfile or JSON config:

kuhnweblab.com {
        root * /var/www/kuhnweblab.com/public
        php_fastcgi unix//run/php/php7.2-fpm.sock
}
xy.app {
        root * /var/www/xy.app
}

xy.app {
        reverse_proxy localhost:3000
}

xy.app {
        reverse_proxy localhost:802
}

3. The problem I’m having:

Browsers interprets the CSS files as text/plain.

4. Error messages and/or full log output:

No Error in logs

5. What I already tried:

Check local mime types:

$ cat /etc/mime.types | grep text/css
text/css					css

6. Links to relevant resources:

None

Is there anything at https://kuhnweblab.com/css/app.css ? I am getting a content length of 0.

Yes, its 99554 Bytes big. I changes nothing on my site. I only upgraded caddy…

Since you’re using the php_fastcgi directive, @francislavoie might have a better idea as to what’s going on…

My guess is that you don’t have the static file server enabled. Is your PHP backend serving up static CSS assets too?

Well, you upgraded Caddy and wrote a new Caddyfile, necessarily, so there could be something wrong with the Caddyfile you wrote too.

1 Like

Yes you are right :sweat_smile:

Thanks for your hints and quick reply. :bowing_man:

Solution:
I added the static_file directive to my kuhweblab config, and everything works as I want.

1 Like

Yeah to clarify, in Caddy v2, there’s no file server enabled by default, you need to add file_server. From the looks of your Caddyfile you posted earlier, you’d need to add that for your kuhnweblab.com site and your first xy.app site.

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.