Equivalent of NGINX "proxy_pass_header Server;"

Caddy version: latest v2
Config format: JSON is OK!

Is there an equivalent of NGINX “proxy_pass_header Server;” in Caddy?

If the proxied response has “Server” header sent by the upstream,
then pass it to the client.
Else, “Server: Caddy”


Caddy passes all response headers downstream as-is. The Server header is always added by Caddy. This is correct behaviour, because then you see both servers that handled the request. It’s useful debugging information.


  1. (Not work)
handler: reverse_proxy
        - '{http.reverse_proxy.header.Server}'
  1. (Upstream response is discarded)
  - match:
          - '*'
      - handle:
          - handler: headers
                  - '{http.reverse_proxy.header.Server}'

So as of now there’s no way to do this.

I’m not sure how to answer that.

Please fill out the help topic template, as per the forum rules. There’s missing important context here which makes it difficult for us to help.

Thanks for your reply!

This is YAML config which is then transformed to JSON config.

No. 1 doesn’t work because {http.reverse_proxy.header.*} placeholder is only available in reverse_proxy.handle_response’s handler chain.

No. 2 doesn’t work because according to the doc it’s designed to let the reverse_proxy.handle_response’s handler chain replace the upstream response body.

So, all these are expected behavior :slight_smile:

I’ve given up on this, and posted the reply to inform other people looking for the solution:
unfortunately but it seems that there’s no way to do this :slight_smile:

1 Like

Hi @bohan,

Caddy automatically includes all Server headers it’s given and sends them downstream.

For example, when I curl my own Nextcloud site, I get:

server: Caddy
server: Apache/2.4.54 (Debian)

Because my Nextcloud container runs Apache internally.

This is the expected behaviour. If you’re not seeing this, you may have a misconfiguration somewhere.

1 Like

Oh, I’m using NGINX in front of Caddy.
NGINX is configured with proxy_pass_header Server;

Maybe NGINX is only passing Server: Caddy
and e.g. Server: Apache/2.4.54 (Debian)
has been replaced.

Thank you all!

1 Like

Yeah, if nginx is in front and it’s only passing on one of the two Server headers it’s getting from Caddy, there must be some way surely to get nginx to capture all of them faithfully instead…

I can’t imagine a web server like nginx would just leave you with no way to properly handle cases where there’s more than one of the same header!

1 Like

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