Port exposure
Exposing a port gives it a public HTTPS URL:
https://<port>-<id-part>.wardcase.comid-part is the sandbox id without its sbx_ prefix, because underscores are not allowed in hostnames. Port 8000 of
sbx_4f9k2m8q1z7x3c5v is served at https://8000-4f9k2m8q1z7x3c5v.wardcase.com.
Expose a port
Section titled “Expose a port”Start a server that listens on 0.0.0.0, then expose its port:
// Start a server that listens on all interfaces, then expose its port.await sbx.run("nohup python -m http.server 8000 --bind 0.0.0.0 > /tmp/http.log 2>&1 &");const { url } = await sbx.expose(8000, { access: "public" });console.log(url); // https://8000-4f9k2m8q1z7x3c5v.wardcase.com
// Token access (the default) returns the token once.const { url: privateUrl, token } = await sbx.expose(8080);await sbx.unexpose(8080);# Start a server that listens on all interfaces, then expose its port.sbx.run("nohup python -m http.server 8000 --bind 0.0.0.0 > /tmp/http.log 2>&1 &")exposure = sbx.expose(8000, access="public")print(exposure.url) # https://8000-4f9k2m8q1z7x3c5v.wardcase.com
# Token access (the default) returns the token once.private = sbx.expose(8080)print(private.url, private.token)sbx.unexpose(8080)Or with the API:
curl https://api.wardcase.com/v1/sandboxes/sbx_4f9k2m8q1z7x3c5v/ports \-H "Authorization: Bearer $VIVARIUM_API_KEY" \-H "Content-Type: application/json" \-d '{"port":8000,"access":"public"}'A server that listens only on 127.0.0.1 inside the sandbox cannot be reached this way. Bind it to 0.0.0.0.
Requests to a port where nothing is listening get a 502 response.
Public or token access
Section titled “Public or token access”access is public or token, and the default is token.
public: anyone with the URL can reach the port.token: the create response carries atoken, once. We store only its hash. Open the URL once with the token as thetokenquery parameter, for examplehttps://8000-4f9k2m8q1z7x3c5v.wardcase.com/?token=<token>. The edge then sets a cookie namedvv_exp_<exposure_id>that holds the token, and requires that cookie on every later request. Browsers keep it on their own; for scripts, keep a cookie jar, for example withcurl -c jar -b jar.
How requests reach the sandbox
Section titled “How requests reach the sandbox”Requests go to Cloudflare, which checks the exposure and forwards them through a tunnel to the sandbox’s host. The host passes them to the sandbox’s port. WebSocket connections pass through too.
Each exposed port is a first-level subdomain of wardcase.com, so Cloudflare Universal SSL covers
it with a valid certificate.
List and remove
Section titled “List and remove”GET /v1/sandboxes/{id}/ports lists a sandbox’s exposed ports. DELETE /v1/sandboxes/{id}/ports/{port} removes one.
Exposures end when the sandbox is destroyed.
What the audit trail records
Section titled “What the audit trail records”port.exposed and port.unexposed for each change, with the URL and the access mode. Requests to the port are not
recorded: the catalogue defines a sampled port.request event, but the edge does not emit it.