Skip to main content
Guide

Expose ports

Run an HTTP server inside a sandbox, publish its port, and get an HTTPS URL.

Publish an anonymous port

Anonymous ports are public HTTPS routes to a process that listens inside the sandbox. Bind the server to 0.0.0.0, not 127.0.0.1.

  1. Open the sandbox from Sandbox groups > your group > Sandboxes.
  2. Start your server from the Interactive shell. Listen on port 8080.
  3. Select Details.
  4. In Ports, select Add port.
  5. Enter 8080 for Port and choose Anonymous for access.
  6. Select Add. Copy the generated URL after the port appears.
aca sandbox create --disk ubuntu --label name=demo-port
aca sandbox exec -l name=demo-port -c \
"nohup python3 -c \"import http.server,socketserver; h=http.server.BaseHTTPRequestHandler; h.do_GET=lambda s:(s.send_response(200),s.end_headers(),s.wfile.write(b'hello from sandbox\\n')); socketserver.TCPServer(('0.0.0.0',8080), h).serve_forever()\" > /tmp/srv.log 2>&1 &"

URL=$(aca sandbox port add -l name=demo-port --port 8080 --anonymous -o json | jq -r '.[].url')

echo "Live at: $URL"
curl -s --max-time 15 "$URL"

Remove a port

Remove a port when the server is no longer needed. The URL stops working immediately.

  1. Open the sandbox, then select Details.
  2. Find the port in Ports.
  3. Select Remove from the row actions.
  4. Confirm the removal.
aca sandbox port remove -l name=demo-port --port 8080