Skip to content

No Placeholders in Active Health Checking Headers #5686

@PoneyClairDeLune

Description

@PoneyClairDeLune

Version

Caddy: 2.7.2

Bug description

When defining a header in the active health checker, placeholders as header values do not get interpreted altogether.

Expected behaviour

Placeholders set in active health checker headers should be interpreted normally as everywhere else in the Caddyfile.

Steps of bug reproduction

  1. Set a new web server for request catching. This can either be a Caddy server, or any new web server spun up with any language.
    Example Caddyfile snippet and WingBlade (JavaScript) web server snippet below.
http://127.0.0.1:8081 {
	log {
		level INFO
	}
	handle /api/example {
		respond "OK"
	}
}
"use strict";

WingBlade.web.serve(async function (request) {
	console.info("New request received. Header info below.");
	request.headers.forEach((value, key) => {
		console.info(`${key}: ${value}`);
	});
	return new Response("OK", {
		status: 200
	});
});
  1. Set a header in a new reverse proxied target with an active health checker. Example Caddyfile snippet:
...
health_uri "/api/example"
health_headers {
	X-Hostname "{system.hostname}"
}
...
  1. Reload the Caddyfile.
  2. Check the sent headers in the target. Prettified Caddy log entry and WingBlade service log outputs are below.
{
	"level": "info",
	"ts": 1691110717.1085844,
	"logger": "http.log.access",
	"msg": "handled request",
	"request": {
		"remote_ip": "127.0.0.1",
		"remote_port": "41368",
		"client_ip": "127.0.0.1",
		"proto": "HTTP/1.1",
		"method": "GET",
		"host": "127.0.0.1:8081",
		"uri": "/api/example",
		"headers": {
			"User-Agent": ["Go-http-client/1.1"],
			"X-Hostname": ["{system.hostname}"],
			"Accept-Encoding": ["gzip"]
		}
	},
	"bytes_read": 0,
	"user_id": "",
	"duration": 0.003900064,
	"size": 2,
	"status": 200,
	"resp_headers": {
		"Server": ["Caddy"],
		"Content-Type": ["text/plain; charset=utf-8"]
	}
}
New request received. Header info below.
User-Agent: Go-http-client/1.1
X-Hostname: {system.hostname}
Accept-Encoding: gzip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions