container: Implement setEgressHttp for containers#5985
Conversation
|
builds are failing because proxy-everything is not being pulled by default, I will check if we can pull it when we try to start it |
Merging this PR will degrade performance by 16.29%
Performance Changes
Comparing Footnotes
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5985 +/- ##
==========================================
- Coverage 70.73% 70.55% -0.18%
==========================================
Files 409 409
Lines 109253 109530 +277
Branches 18007 18037 +30
==========================================
+ Hits 77276 77281 +5
- Misses 21171 21438 +267
- Partials 10806 10811 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2cf6f25 to
28029df
Compare
3cff408 to
aae56c4
Compare
kentonv
left a comment
There was a problem hiding this comment.
I've only looked at the interfaces so far. Happy to trust Dan's review of implementation details.
aae56c4 to
6c23e85
Compare
6cff1b0 to
6ccb392
Compare
|
rebased conflict. |
ef6cb2c to
fd9440d
Compare
c258d4c to
af4655c
Compare
|
rebased |
danlapid
left a comment
There was a problem hiding this comment.
lgtm, only thing left is the excess attachments, feel free to patch that out and merge.
…r interface Add new Cap'n Proto schema definitions for container egress routing: - setEgressTcp: configures TCP egress routing to Workers runtime - setEgressHttp: configures HTTP egress routing to Workers runtime Also add Docker API schema additions to support the networking features we will need to introduce proxy-everything.
Refactor BUILD.bazel to split channel-token.c++ and channel-token.h. This allows container-client to depend on channel-token.
Expose setEgressHttp() to JavaScript, allowing Workers to register WorkerEntrypoint bindings for container egress routing. The method is gated behind the workerdExperimental flag.
Implement the workerd handling for container egress HTTP routing: - EgressHttpService: HTTP service that handles CONNECT requests from proxy-everything (https://hub.docker.com/r/cloudflare/proxy-everything), it parses tunneled HTTP requests, and forwards them to the appropriate SubrequestChannel based on registered mappings - We need to do proxy-everything container management: we create and monitor a sidecar container (proxy-everything) that shares network namespace with the main container and intercepts outbound traffic via iptables/TPROXY. - Egress listener: HTTP server listening on the Docker bridge gateway that receives proxied requests from proxy-everything. - setEgressHttp RPC implementation that registers address to SubrequestChannel mappings. WebSocket is currently unimplemented. It's a TODO.
Add containerEgressInterceptorImage field to DockerConfiguration in workerd.capnp with default value 'cloudflare/proxy-everything:main' Pass ChannelTokenHandler and containerEgressInterceptorImage through WorkerService -> ActorNamespace -> ContainerClient chain Update ContainerClient instantiation to include the new parameters
Add a new /intercept HTTP endpoint to the test container that makes an outbound fetch request to a configurable host (via x-host header, defaults to 11.0.0.1). This enables testing of egress HTTP routing where container traffic is intercepted and routed back to Workers bindings.
Add test coverage for the setEgressHttp functionality. Also adds enable_ctx_exports compatibility flag to test config and updates TypeScript type definitions with setEgressHttp signature.
for tests in bazel
…e exit experimental phase
af4655c to
73210ab
Compare
Continuation of: #5939
The main implementation of container-client.c++ has been mostly navigated through Claude Opus 4.5.
We are implementing a HTTP CONNECT service in Workerd that intercepts all TCP traffic off the container thanks to https://hub.docker.com/r/cloudflare/proxy-everything.
We then check configured mappings of the container, if the targetted host exists in the mappings, we redirect to that subrequest channel. If not, we check if enabledInternet is set to true, which then we just connect directly to the internet. If set to false, we just close the connection.