Caddy is not honoring custom Server banners for 308 redirects

1. Caddy version (caddy version):

v2.5.1 h1:bAWwslD1jNeCzDa+jDCNwb8M3UJ2tPa8UZFFzPVmGKs=

2. How I run Caddy:

Via services

a. System environment:

Ubuntu

b. Command:

N/A

c. Service/unit/compose file:

N/A

d. My complete Caddyfile or JSON config:

(customheaders) {
        header /* {
                Server "My Header"
		}
}
thisismysite.com {
        import customheaders

        root * /var/www/html
        file_server
        import logs

        handle_errors {
                @404 {
                        expression {http.error.status_code} == 404
                }
                handle @404 {
                        rewrite * /404.html
                        file_server
                }
        }
}

3. The problem I’m having:

308 Redirects add the Server header for “Caddy” despite the custom header directive being set in the config.

4. Error messages and/or full log output:

N/A

5. What I already tried:

I’ve tried several different combinations of overwriting the server banner to no avail. Caddy should be honoring the custom server directive for everything globally.

6. Links to relevant resources:

Are you talking about Caddy’s built-in redirects from HTTP to HTTPS? Your Caddyfile only configures the HTTPS site. You can override the built-in HTTP site by adding a http://thisismysite.com block so that Caddy will use that instead.

No way is that true, though: the snippet is only imported to your thisismysite.com block. You don’t have a catch-all :80 block to apply it towards.

In the future, please fill out the help template completely. It’s against our forum rules to skip sections and redact domain names because it makes our job to help you a lot harder. :frowning:

1 Like

Thanks for the response Matt. I had only redacted sections that I felt weren’t relevant to the issue, but I understand the desire for having consistency and point taken. That said, the points you made on this led me down the path to resolving this issue so thank you for that.

My apologizes for not following the format as cited. This won’t be an issue moving forward.

1 Like

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