> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# HTTPS

> Every machine gets an HTTPS domain automatically.

Every machine gets a domain at `<machine>.boxd.sh`, or at `<machine>.nyc.boxd.sh` for a machine in [New York](/guides/regions.md). The boxd [proxy](/guides/proxies.md) terminates TLS and forwards HTTP requests to your machine.

```text
https://myapp.boxd.sh  ->  your machine, the port your app listens on (8000 if none is detected)
```

## Get started

nginx is pre-installed and configured on port 8000, but disabled by default. Start it:

```bash
boxd machine exec myapp -- sudo systemctl start nginx
```

Visit `https://myapp.boxd.sh` to see a welcome page.

## Run your own app

The default proxy detects the port your app listens on among 80, 443, 8080, 8000, 3000, 5000 and 5173, and falls back to 8000. A process listening on one of those ports is reachable over HTTPS with no configuration.

```bash
# Python
boxd machine exec myapp -- python3 -m http.server 8000

# Go
boxd machine exec myapp -- "/home/boxd/app/server -port 8000"
```

## Change the port

To send the default proxy to a specific port, set it from your laptop:

```bash
boxd machine proxy set-port --vm myapp --port 3000

# Back to auto-detecting the listening port
boxd machine proxy set-port --vm myapp --port auto
```

Inside a machine, leave out `--vm` to target the machine you are in:

```bash
boxd machine proxy set-port --port 3000
boxd machine proxy set-port --port auto
```

## Subdomain proxies

Create additional subdomains pointing to different ports:

```bash
# api.myapp.boxd.sh -> port 3001
boxd machine proxy add api --vm myapp --port 3001

# List all proxies
boxd machine proxy list --vm myapp

# Remove a proxy
boxd machine proxy remove api --vm myapp
```

Each of these is a proxy, the same kind of object as the default one. The [Proxies](/guides/proxies.md) guide covers them in full: creating and removing them, changing target ports, and how routing works.

## WebSockets

WebSocket connections work transparently. The proxy detects the `Upgrade: websocket` header and forwards the connection.

## Non-HTTP traffic

The HTTPS proxy speaks HTTP only: it terminates TLS and routes by domain. To reach a database, an SSH daemon, a game server, or any other raw protocol, add a raw port forward instead:

```bash
boxd machine proxy add --vm myapp --port 5432 --raw   # myapp.boxd.sh:<allocated-port> -> :5432 in the machine
```

See [Port forwarding](/guides/port-forwarding.md).

## HTTP to HTTPS

Plain HTTP requests to `http://<machine>.boxd.sh` are redirected to HTTPS automatically. HSTS headers are included in the response.

## DNS

A DNS record is created automatically when your machine boots. The record has a 60-second TTL.

```text
myapp.boxd.sh  ->  A record  ->  proxy's public IP
```

Every machine's domain points at the proxy's shared public IP. The proxy routes HTTPS by SNI (the domain in the TLS handshake) and SSH by the machine's dedicated port, so the same IP fronts every machine. A machine in New York points at New York's proxies.

## Custom domains

You can use your own domain instead of `<machine>.boxd.sh`: one domain for one machine, or a wildcard delegated to your whole organization. See [Custom domains](/guides/custom-domains.md).
