caddy icon indicating copy to clipboard operation
caddy copied to clipboard

Caddy does not pass 103 (Early Hints) headers through the reverse proxy chain

Open lermontex opened this issue 1 year ago • 3 comments

I'm using Docker Compose to initialize multiple containers

I have fastify app + @fastify/early-hints - (http://container1.node.local:3000)

app.get("*", async (request, reply) => {

await reply.writeEarlyHintsLinks([
    { href: "/index.js", rel: "preload", as: "script" },
    { href: "/index.css", rel: "preload", as: "style" }
]);

// some work

await reply
        .code(200)
        .type("text/html")
        .header("X-Test", "Test header")
        .send(html);
});

Proxy Server 1 (https://container1.caddy.local):

Caddyfile

#...
reverse_proxy http://container1.node.local:3000

Proxy Server 2 (https://container2.caddy.local):

Caddyfile

#...
reverse_proxy {
    header_up Host container1.caddy.local
    to https://container1.caddy.local
    transport http {
        tls_insecure_skip_verify
        tls_server_name container1.caddy.local
        read_buffer 8192
    }
    header_down -Server
}

I am running requests:

curl -k -v --http2 http://container1.node.local:3000 - OK (X-Test Custom Header present, 103 Early Hints Headers present) curl -k -v --http2 https://container1.caddy.local - OK (X-Test Custom Header present, 103 Early Hints Headers present) curl -k -v --http2 https://container2.caddy.local - BAD (X-Test Custom Header present, 103 Early Hints Headers missing)

Is this a bug or is it supposed to be like this? Is it possible to configure Caddy so that headers are passed along the entire chain?

lermontex avatar Jan 15 '24 17:01 lermontex

/cc @dunglas

francislavoie avatar Jan 15 '24 18:01 francislavoie

I am not actually sure what the expected behavior for 1xx is -- maybe it's hop-by-hop? Seems like it should go through, though. I'll leave it up to @dunglas when he has a chance :)

mholt avatar Apr 17 '24 18:04 mholt