Certain Static Files Returning Default index.html File

1. Caddy version (caddy version):

v2.2.1 h1:Q62GWHMtztnvyRU+KPOpw6fNfeCD3SkwH7SfT1Tgt2c=

2. How I run Caddy:

a. System environment:

Linux (Ubuntu 18.04) amd64, manual run.

b. Command:

sudo -E caddy start --config /etc/caddy/Caddyfile

sudo -E pulls in my api key for cloudflare.

d. My complete Caddyfile or JSON config:

aftermath.space {
        encode gzip
        tls {
                dns cloudflare {env.CLOUDFLARE_AUTH_TOKEN}
        }
        root * /var/www/landing
        file_server
}

forums.aftermath.space {
        tls {
                dns cloudflare {env.CLOUDFLARE_AUTH_TOKEN}
        }

        root * /var/www/afterlife
        encode gzip zstd
        try_files {path} {path}/ /index.html
        file_server
}

3. The problem I’m having:

I am running a react app where the folder inside of forums.aftermath.space (root dir). Trying to load up the url gives me errors, as some of the files within the html file are being interpreted as html instead of JS/CSS. Upon closer inspection, it seems that some files within the static/css directory are not being found by Caddy and instead the default index.html file is being returned. I tried putting in the url manually, and this confirmed that theory, as some urls in the html file would return the normal js / css content, while others would return the index page. I tried opening them up manually within the terminal, and the files are correct on the outside, so it must be something messing up somewhere.

Does anyone have any idea what’s going on with this? It makes little sense to me. I tried with multiple browsers and PCs, the same issue occurred.

4. Error messages and/or full log output:

N/A

5. What I already tried:

I’ve loaded pretty much every Caddyfile template I could find and have had no success getting stuff to load properly.

What does the file structure look like? You can use the tree command to show it. What files work and which don’t?

Your config looks right to me at a glance but without knowing the file structure it’s hard to make guesses as to the problem

I believe the problem may lay somewhere else now. Despite being stuck on this issue all day, it has suddenly fixed itself without any change within the config file, a reboot, or similar. However, about 20 minutes later it stopped working again. I think the problem may lie upstream in some other repo, library, or something else.

I’ll investigate further, and come back here should I have anything worthy of note or additional information. Sorry for taking your time.

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