Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh

Commit

A container app is sent each request over plain HTTP, as it listens, with the visitor's scheme and host as X-Forwarded-Proto and X-Forwarded-Host: the request went on with its https:// address, the container's port was asked for TLS, and the app closed the connection (502, "It closed the connection before it answered").

syntaqxcommitted Parent1d1a13eBrowse files
1 file+16−10/1 viewed
+16−1
328328 }
329329 let response;
330330 try {
331− response = await container.getTcpPort(port).fetch(request);
331+ // To the container over plain HTTP, as the app listens: the visitor's
332+ // https:// address would have the port asked for TLS, and the app
333+ // close the connection. The path, query, method, headers and body
334+ // stay as they came; the original host and scheme go along as
335+ // X-Forwarded-* headers.
336+ const url = new URL(request.url);
337+ const headers = new Headers(request.headers);
338+ headers.set("x-forwarded-proto", url.protocol.replace(":", ""));
339+ headers.set("x-forwarded-host", url.host);
340+ const inner = new Request("http://container" + url.pathname + url.search, {
341+ method: request.method,
342+ headers,
343+ body: request.body,
344+ redirect: "manual",
345+ });
346+ response = await container.getTcpPort(port).fetch(inner);
332347 } catch (error) {
333348 return page(502, "The app failed", "It closed the connection before it answered.");
334349 }