All assets being transferred as MIME type text/plain - Caddy 2

1. Caddy version (caddy version):

v2.4.0-beta.2

2. How I run Caddy:

a. System environment:

Ubuntu 18.04

b. Command:

sudo systemctl restart caddy

c. Service/unit/compose file:

none

d. My complete Caddyfile or JSON config:

(baseSetup) {
    root * /var/www/darrenter/public
    php_fastcgi unix//run/php/php7.4-fpm.sock
    encode gzip zstd

    header {
        Strict-Transport-Security "max-age=31536000; includeSubDomains; preload; always"
		X-Frame-Options "SAMEORIGIN"
		X-XSS-Protection "1; mode=block"
		X-Content-Type-Options "nosniff"
    }

    log {
        output file /var/log/caddy/access.log {
            roll_size 1gb
            roll_keep 100
            roll_keep_for 2160h
        }
    }
}

darrenter.cyou {
    import baseSetup
}

*.darrenter.cyou {
    import baseSetup

    tls {
        dns cloudflare {API Token}
    }
}

https:// {
    import baseSetup

    tls {
        on_demand
    }
}

3. The problem I’m having:

When I visit my site, all the requests of styles, js and media return 200 but they doesn’t apply correctly to my site.

When taking a look at the headers of one of the files, seems like Content-type is missing

curl -I https://darrenter.cyou/css/app.css

HTTP/2 200 
server: Caddy
date: Sun, 04 Apr 2021 17:33:28 GMT

4. Error messages and/or full log output:

No error messages from Caddy so far.

5. What I already tried:

I have tried to manually declare a header for the css file, but still doesn’t work

Content-Type "text/css"

6. Links to relevant resources:

You’re missing file_server in your config.

Caddy is not configured to handle requests to anything but .php files, so it can only respond with empty 200 responses.

2 Likes

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