Skip to content
28 changes: 19 additions & 9 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,12 @@ and SERVICE_START rejects a `duration` outside it:

Environments on the same engine may therefore report different values for both.

`features` (`{ computeJobs, services, secureTls? }`) tells what an environment accepts.
`secureTls: true` means service ports can be served over HTTPS (`secureTls` in `serviceStart` /
`serviceRestart`): the environment is the node's first local Docker environment, its `nodeHost`
is a public IP or a domain, and the node's Caddy accepted the last update. An older
node omits it; treat a missing value as `false`.

Both fields are additive, and an older node omits them. Their fallbacks differ, so treat each
separately:

Expand Down Expand Up @@ -2730,6 +2736,7 @@ Operator-published blueprint. Secret `envVars` values are never returned — onl
| image | string | base image |
| tag / checksum / dockerfile | string | image spec — exactly one |
| exposedPorts | number[] | container ports to forward |
| secureTls | number[] | HTTP ports to request over HTTPS (subset of exposedPorts) |
| envVarKeys | string[] | keys of operator-set env vars (values never returned) |
| userConfigurableEnvVars | object[] | `{ key, validation?, sensitive? }` passed via `userData` |
| command / entrypoint | string[] | Docker CMD / ENTRYPOINT overrides |
Expand Down Expand Up @@ -2768,14 +2775,15 @@ The encrypted `userData` is never returned. Key fields:
| environment | string | envId the service runs on |
| owner | string | consumerAddress |
| status | number | `10` Starting, `20` Locking, `11` PullImage, `13` BuildImage, `30` Claiming, `40` Running, `12` PullImageFailed, `14` BuildImageFailed, `15` VulnerableImage, `50` Stopping, `70` Stopped, `75` Expired, `76` DiskQuotaExceeded (restartable/editable like Stopped until expiresAt), `99` Error |
| statusText | string | human-readable status |
| dateCreated | string | ISO timestamp |
| expiresAt | number | Unix ms timestamp when the paid window ends |
| duration | number | requested seconds |
| endpoints | object[] | `{ containerPort, hostPort, url }` per exposed port |
| resources | object[] | `{ id, amount, price }` |
| payment | object | initial start payment record |
| extendPayments | object[] | one entry per successful extend |
| statusText | string | human-readable status |
| dateCreated | string | ISO timestamp |
| expiresAt | number | Unix ms timestamp when the paid window ends |
| duration | number | requested seconds |
| endpoints | object[] | `{ containerPort, hostPort, url, tls }` per exposed port. `tls: true` → `url` is `https://<nodeHost>:<hostPort>` (served by the node's Caddy); otherwise `http://` |
| secureTls | number[] | container ports served over HTTPS; absent when none |
| resources | object[] | `{ id, amount, price }` |
| payment | object | initial start payment record |
| extendPayments | object[] | one entry per successful extend |

---

Expand Down Expand Up @@ -2869,7 +2877,8 @@ should keep watching `serviceStatus`, not just stop once they first see `Running
| duration | number | v | seconds; capped by `serviceOnDemand.maxDurationSeconds` |
| userData | string | | ECIES-encrypted (to the node pubkey) JSON of env vars |
| metadata | object | | arbitrary user labels (`string`/`number`/`boolean` values, ≤1 KB JSON); node-opaque. Returned on both `serviceStatus` and `serviceList` |
| payment | object | v | `{ chainId, token }` |
| secureTls | number[] | | exposed HTTP container ports to serve over HTTPS (unique). Needs `features.secureTls` on the environment (else 400). TLS only: authentication is the image's own job. See [services.md](services.md#https-endpoints-securetls) |
| payment | object | v | `{ chainId, token }` |

#### Response (200)

Expand Down Expand Up @@ -3065,6 +3074,7 @@ RESPEC mode (restart on a new image spec — `image` required, plus at most one
| dockerCmd | string[] | | exact container command (Docker exec-form CMD override) |
| dockerEntrypoint | string[] | | container ENTRYPOINT override |
| metadata | object | | user labels (≤1 KB JSON). **Not** a container param — independent of REUSE/RESPEC. When present it **replaces** the stored metadata; when omitted the original metadata is kept |
| secureTls | number[] | | container ports, like `serviceStart`. **Not** a container param. When present it **replaces** the stored list (`[]` turns TLS off); when omitted the stored list is kept. A non-empty list needs `features.secureTls` (else 400). An omitted list drops TLS only when the node's config no longer allows it (e.g. `nodeHost` is now private); while TLS is only temporarily unavailable, the stored list is kept |
| ports | object[] | | `{ containerPort, hostPort? }[]` — change the ports, optionally **pinning** host ports (`hostPort` omitted = auto-allocate). Independent of REUSE/RESPEC (no `image` required). Validated/reserved up front: an unavailable requested host port is rejected and the running service is **left untouched**; on success the old host ports are freed after teardown and the `endpoints`/URLs change. Omitted ⇒ keep current ports. (The legacy `exposedPorts` field is **not** read on restart — use `ports`.) |

#### Response (200)
Expand Down
43 changes: 43 additions & 0 deletions docs/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,49 @@ When a TLS certificate is provisioned successfully, you will see logs like:
----- End of TLS addresses -----
```

## Service TLS: the Caddy proxy

Services can serve their ports over HTTPS (see [services.md](services.md#https-endpoints-securetls)).
TLS is done by the official [Caddy](https://caddyserver.com/) image. The node starts and manages
it; you do not add it to your compose file.

- The node runs one container, `ocean-node-caddy` (`caddy:2.11.9-alpine`, host network,
restart `always`, certificates in the `ocean-node-caddy-data` volume). It sends Caddy the
config with `docker exec`, to Caddy's admin API on the host's `127.0.0.1:2019`.
- Only the first local (`socketPath`) Docker environment does this, with its
`serviceOnDemand.nodeHost` as the certificate name: a public IP or a domain. With
`localhost` or a private IP, service TLS is off and the node logs one line asking you to set
it.
- The node sends the config when the services change, and again every minute (so a restarted
Caddy gets it back). An environment shows `features.secureTls: true` only after Caddy
accepted the last config. Caddy's log: `docker logs ocean-node-caddy`.
- Open the service `hostPortRange` (TCP), as for plain services: Caddy listens on the secure
host ports.
- One ocean-node with service TLS per Docker host: Caddy binds the host's port 80 and admin port 2019. A second node finds `ocean-node-caddy` owned by the first and keeps TLS off.

### Certificate from Let's Encrypt (default)

Caddy gets and renews a Let's Encrypt certificate for `nodeHost` on its own, with the
`shortlived` profile (needed for IP certificates). **Port 80 must be free**: Let's Encrypt
checks the name with an HTTP request on port 80, and Caddy (host network) answers it.

### Nodes where a proxy already holds ports 80 and 443

If another proxy (for example Traefik) holds ports 80 and 443, it answers every certificate
check there. Caddy cannot get a certificate, and IP certificates are not possible. Caddy then
uses the Let's Encrypt certificate that the proxy already has for your domain. The proxy does
not change, and it keeps renewing the certificate.

1. Set `serviceOnDemand.nodeHost` to a domain that the proxy has a certificate for (for example
`cp1.oncompute.ai`).
2. Set `serviceOnDemand.letsEncryptAcmePath` to the **host** path of the proxy's `acme.json` (for
example `/home/ubuntu/ocean/letsencrypt/acme.json`). The file must be in Traefik's
`acme.json` format. The node mounts it read-only into Caddy; the node cannot read it itself,
because the file is owned by root with mode 600.

The node copies the certificate for `nodeHost` into Caddy, and copies it again after a renewal.
In this mode Caddy does not bind port 80.

## Verifying Connectivity

### Check how your node sees itself
Expand Down
Loading
Loading