LogoFreestyle

Domains

Map custom domains to VM services.

Freestyle lets you attach custom domains to ports running inside your VM. Configure domains when creating the VM, and Freestyle will provision HTTPS for each domain.

Quick Start

import { freestyle } from "freestyle-sandboxes";
import { VmSpec } from "freestyle-sandboxes";

const domain = "vm-domain-test.style.dev";

const snapshot = new VmSpec({
  aptDeps: ["python3"],
  systemd: {
    services: [
      {
        name: "http-server",
        mode: "service",
        exec: ["/usr/bin/python3 -m http.server 3000 --directory /root"],
      },
    ],
  },
});

const { vmId, domains } = await freestyle.vms.create({
  snapshot,
  additionalFiles: {
    "/root/index.html": {
      content: `<html><body><h1>Hello, Freestyle VM!</h1></body></html>`,
    },
  },
  domains: [
    { domain, vmPort: 3000 },
  ],
});

console.log(vmId);
console.log(domains); // Resolved domains

Domain Mapping

Each entry in domains maps a public domain to a port inside the VM:

  • domain: the public hostname (must be routable to Freestyle)
  • vmPort: the port inside the VM to route traffic to
const { domains } = await freestyle.vms.create({
  domains: [
    { domain: "app.example.com", vmPort: 3000 },
    { domain: "admin.example.com", vmPort: 4000 },
  ],
});

Notes

  • Domains are returned in the domains array of the create response.
  • HTTPS is provisioned automatically for each domain.
  • Your service must listen on the specified vmPort (e.g. 0.0.0.0:3000).

On this page

Freestyle AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details with the official documentation.

How can I help?

Ask me about Freestyle while you browse the docs.