Custom Headers#

PosternProxy can inject, modify, or remove HTTP headers on requests sent to your upstream and on responses returned to clients. Header rules are configured on the Headers tab.

Adding a rule#

Each rule has four fields:

FieldOptionsDescription
DirectionRequest / ResponseWhether the rule applies to the upstream request or the downstream response
OperationSet / Add / DeleteWhat to do with the header
NameAny stringThe header name (case-insensitive)
ValueAny stringThe header value (not used for Delete)

Click + Add Rule to insert a new row. Rows with an empty Name are ignored on save.

Use valid HTTP header names and values. Invalid operations can be rejected when Caddy applies the generated configuration.

Headers tab setting X-Frame-Options to DENY and deleting the Server response header

Unsaved example response-header rules added through the built-in presets.

Operations#

OperationBehaviour
SetCreates the header if absent; replaces it if already present
AddAppends the value (creates a new header instance — does not replace existing values)
DeleteRemoves all instances of the header

Presets#

The Headers tab includes a Presets panel with six common rules you can add with a single click:

PresetRule
Hide Server headerDelete Server from response
Hide X-Powered-ByDelete X-Powered-By from response
CORS Allow-Origin *Set Access-Control-Allow-Origin: * on response
X-Frame-Options DENYSet X-Frame-Options: DENY on response
Cache-Control no-storeSet Cache-Control: no-store on response
X-Request-ID passthroughSet X-Request-ID: {http.request.uuid} on request

How it works#

Custom headers are implemented as a standalone Caddy headers handler placed before the reverse_proxy handler in the route chain:

  • Request headers are modified before the request is forwarded upstream.
  • Response headers are modified after the upstream response is received, using Caddy’s Deferred mode so that the response body is not buffered.

Dynamic values#

Caddy supports placeholder variables in header values. You can use these in the Value field:

PlaceholderResolves to
{http.request.remote.host}Immediate client connection IP address
{http.request.scheme}http or https
{http.request.host}Request host
{http.request.method}HTTP method
{http.request.uri}Full request URI

Notes#

  • With NTLM authentication passthrough on, a rule is rejected when it can change the request Authorization header or the response WWW-Authenticate header. That includes a delete of * and other wildcard deletes that match those names, and any header name containing {, }, :, or a line break. Other rules, including the presets on this page, can still be saved. The Security tab warns against header rules on these hosts because they can break Integrated Windows Authentication.
  • Rules are grouped into Caddy set/add/delete operations. Avoid contradictory operations on the same name; row order is not a general ordering guarantee.
  • Response header rules are applied after the upstream responds. They cannot prevent upstream from sending a header; they can only modify the copy that reaches the client.
  • Header names are case-insensitive per HTTP/1.1 spec; Caddy normalises them to canonical form.
PosternProxyQuick start →