Network and previews
Daytona controls a sandbox’s network from outside the sandbox, so nothing running inside it can turn the limits off. Two layers decide what goes out. Your organization’s tier sets the floor: below Tier 3, sandboxes reach only an allowlist of essential services, such as package registries, GitHub, AI APIs and Daytona’s own API, and from Tier 3 they reach the whole internet. On top of that, each sandbox can narrow it further.
Your tier sets the floor, each sandbox narrows it
Section titled “Your tier sets the floor, each sandbox narrows it”Allow only some domains
Section titled “Allow only some domains”import * as Daytona from "@alchemy.run/daytona";import { Base } from "./Images.ts";
export const DevBox = Daytona.Sandbox("DevBox", { snapshot: Base, domainAllowList: ["github.com", "registry.npmjs.org"],});Use networkAllowList for CIDR ranges, and networkBlockAll: true to cut the network entirely. All three change in place.
Route traffic through your own proxy
Section titled “Route traffic through your own proxy”import * as Daytona from "@alchemy.run/daytona";import { Base } from "./Images.ts";
export const DevBox = Daytona.Sandbox("DevBox", { snapshot: Base, domainAllowList: ["github.com", "registry.npmjs.org"], outboundProxyUrl: "http://proxy.example.com:3128",});Daytona sets HTTP_PROXY and HTTPS_PROXY in the sandbox to this URL, and enforces it at the network only when the sandbox also has a domainAllowList. It’s a forward proxy: HTTPS requests reach it as CONNECT tunnels, so it runs on a host that accepts them, such as a Fly Machine. A Cloudflare Worker can’t serve CONNECT, so it can’t be one. The URL is in the sandbox’s environment, so the sandbox can read any password in it. To add a credential the sandbox never sees, use a Secret. Changing the URL replaces the sandbox.
Limit sandboxes you create
Section titled “Limit sandboxes you create”const sandbox = yield* sandboxes.create({ domainAllowList: "api.openai.com,github.com", networkBlockAll: false,});yield* sandbox.updateNetworkSettings({ domainAllowList: "github.com" });create takes Daytona’s own request, so the lists are comma-separated strings here.
Reach a port from outside
Section titled “Reach a port from outside”A preview URL reaches a port inside a sandbox through Daytona’s proxy. A private sandbox’s previews need its preview token in the X-Daytona-Preview-Token header; a public sandbox’s previews are open to anyone.
const preview = yield* sandbox.getPortPreviewUrl({ port: 3000 });const signed = yield* sandbox.getSignedPortPreviewUrl({ port: 3000, expiresInSeconds: 3600 });const port = yield* sandbox.getTcpPort(3000);const res = yield* port.fetch(HttpClientRequest.get("/health"));A signed URL works without the token until it expires, so you can hand it to a browser. getTcpPort returns the port’s preview url and token, and its fetch sends a request there with the token for you.
Put a Worker in front of a port
Section titled “Put a Worker in front of a port”fetch also takes the request your Worker received, and returns a response the Worker can send straight back:
const port = yield* sandbox.getTcpPort(3000);return yield* port.fetch(yield* HttpServerRequest);The method, path, query, headers and body go to the sandbox’s server, and its status, headers and body come back. Bodies stream both ways.
Open previews to anyone
Section titled “Open previews to anyone”import * as Daytona from "@alchemy.run/daytona";import { Base } from "./Images.ts";
export const DevBox = Daytona.Sandbox("DevBox", { snapshot: Base, public: true });public changes in place.
Credentials a sandbox can use but not read are in Secrets.