-
Notifications
You must be signed in to change notification settings - Fork 521
container: Implement setEgressHttp for containers #5985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…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.
|
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 improve performance by 22.5%
Performance Changes
Comparing Footnotes
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #5985 +/- ##
==========================================
- Coverage 70.14% 69.98% -0.17%
==========================================
Files 407 407
Lines 107225 107561 +336
Branches 17972 18016 +44
==========================================
+ Hits 75214 75276 +62
- Misses 21228 21495 +267
- Partials 10783 10790 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2cf6f25 to
28029df
Compare
d3b9fa8 to
3cff408
Compare
for tests in bazel
3cff408 to
aae56c4
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.