Caddyfile server all files plus one extra with the html extension

1. The problem I’m having:

Here is my Caddyfile:

    route {
        file_server {
            root /var/www
        }
    }

    reverse_proxy localhost:8080

This works great. Except I have one outlier case. A file chat.html that I want to serve when the url is /chat, not /chat.html.

2. Error messages and/or full log output:

No errors

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

brew services restart caddy

a. System environment:

Linux and MacOS

d. My complete Caddy config:

    route {
        file_server  {
            root /var/www
        }
    }

    reverse_proxy localhost:8080

Your config doesn’t really make sense, all requests will be handled by file_server, and none will ever reach reverse_proxy as-is. You need to use matchers to tell Caddy which requests go where.

When is your proxy meant to be used, exactly?

You should use handle blocks with matchers to split the traffic up.

Then you’d need a rewrite like: rewrite /chat /chat.html (when the /chat path matcher matches, then it rewrites the path to /chat.html).