Setting Header Doesn't Overwrite The "server" header

1. Caddy version (caddy version):

v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

sudo systemctl start caddy

a. System environment:

Ubuntu Server 20.04 LTS
Raspberry Pi 4 
2 GB RAM

b. Command:

sudo systemctl restart caddy

c. Service/unit/compose file:

 check at https://raw.githubusercontent.com/caddyserver/dist/master/init/caddy.service

d. My complete Caddyfile or JSON config:

# Caddyfile
{
    admin 0.0.0.0:2020

    on_demand_tls {
        ask      http://localhost:1234/willissuecert
    }
}

:443 {

  tls ssl@email.xyz {
        on_demand
}

    header / {
      server "PiCDN"
    }


  reverse_proxy * localhost:8000
}

3. The problem I’m having:

I can’t overwrite the ‘server’ header on requests

4. Error messages and/or full log output:

5. What I already tried:

I tried reading the docs and change the header name to lower and upper case.

But it still appears it has the value of ‘Caddy’ when I had set it up to put ‘PiCDN’ there.

6. Links to relevant resources:

Caddyserver | Docs

Path matchers in Caddy v2 operate on exact match principle, not prefix matching. So this:

will only set the server header only if the request was made to /, and not for any other route.

1 Like

Thanks a lot, it worked.

But can I set it like that, it will delete existing “server” header and add its own?

image

The header server: Vercel must be coming from the upstream of the reverse_proxy. Look into the header_down sub-directive of the reverse_proxy directive.

1 Like

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