caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.56k stars 4.05k forks source link

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

Open lermontex opened 10 months ago

lermontex commented 10 months ago

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?

francislavoie commented 10 months ago

/cc @dunglas

mholt commented 7 months ago

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 :)

francislavoie commented 1 month ago

I wonder if https://github.com/caddyserver/caddy/pull/6656 will fix this