Skip to content

Deploy an API service

Run an HTTP API on your instance and reach it over HTTPS through the platform edge.

API deployment - container behind the platform HTTPS edge

What you'll run

A single container exposing an HTTP API on one port. The node edge terminates HTTPS and forwards requests to that port, so you do not need Caddy, a published host port, or a DNS record to get started.

Run the API

bash
$ docker run -d \
--name my-api \
--restart unless-stopped \
-p 8080:8080 \
-e DATABASE_URL=postgresql://user:pass@db:5432/app \
-e NODE_ENV=production \
ghcr.io/yourorg/your-api:latest

Or use Compose. The container only needs to listen on 8080 inside the instance; there is no host port to publish for HTTP traffic.

yaml
services:
api:
image: ghcr.io/yourorg/your-api:latest
restart: unless-stopped
ports: ["8080:8080"]
environment: { DATABASE_URL: "postgresql://user:pass@db:5432/app" }
db:
image: postgres:16-alpine
volumes: ["pg_data:/var/lib/postgresql/data"]
environment: { POSTGRES_DB: app, POSTGRES_USER: user, POSTGRES_PASSWORD: pass }
volumes: { pg_data: {} }

Set the origin port and open the URL

  1. Open the instance's Networking tab.
  2. In Sites, set the web origin to 8080 and save.
  3. Open the HTTPS URL shown there. A custom domain is optional.
bash
$ # Inside the instance:
$ curl -s http://127.0.0.1:8080/health
$ # From anywhere:
$ curl -s https://<hostname>.nairacloud.xyz/health
$ # If .nairacloud.xyz is not resolving yet, use the sslip alias:

Your app sees the original host and client address in X-Forwarded-* headers. If your framework has a trust proxy setting, enable it so generated URLs and client IPs are correct.

Raw TCP, gRPC, and other non-HTTP traffic

The website edge speaks HTTP. For a database, game server, MQTT broker, or raw TCP/gRPC service, use Publish a TCP port in the Networking tab. That gives you tcp://<node-ip>:<host-port>.

Practical -- try it now

Deploy your API in 5 minutes

  1. Provision an instance, SSH in, and run your container on port 8080.
  2. In Sites, set the web origin to 8080.
  3. Call /health on the HTTPS URL from your laptop.
Ask a question...
Ctrl+I