Skip to main content

Web service

A web service is a containerized HTTP application running continuously on ComputeSphere. You give it an image (or a Git repo), tell it which port your app listens on, and the platform terminates TLS at the edge, hands traffic to your spherelets, and load-balances across them.

One request, end to end
Public Internet
A browser, an API client, anything making an HTTPS request.
HTTPS URL
silver-cobra.computesphere.appTLS terminated at the edge.
Serviceapi
3 spherelets — load-balanced.

Web service is the right kind for: APIs, full-stack web apps, single-page app servers, gRPC services (over HTTP/2), reverse proxies — anything that wakes up on a request and writes a response.

What you configure​

FieldWhat it does
NameIdentifier for the service — unique within the project.
PlanSpherelet shape: flex, standard, or performance. See Spherelets for the CPU/memory and pricing for each.
SphereletsHow many copies to run (1–100). Traffic load-balances across them.
PortThe port your app listens on — bound to 0.0.0.0 (not localhost). Required, or the platform can't route requests.
Build sourceimage to pull a pre-built image from a registry, or git to build from a connected repo.
ImageThe registry path (when build_source: image) — e.g. ghcr.io/acme/api:1.0.0.
DockerfilePath to the Dockerfile (when build_source: git) — defaults to Dockerfile.
BranchGit branch to deploy from (when build_source: git) — defaults to main.
Custom domainOptional. Your own hostname instead of (or alongside) the auto-generated *.computesphere.app URL. See Custom domains.
Health checkOptional. An HTTP path the platform polls to know your service is ready. Without it, the rollout assumes "started = healthy".
AutoscalingOptional. CPU-based. Set min/max spherelets and a target. See Auto-scaling.
Environment variablesConfiguration passed into the container — plain values and secret values. See Environment variables.

Build sources​

You ship one of two ways:

  • From an image — you (or your CI) build the image and push it to a registry. ComputeSphere pulls it on deploy. Pairs with the GitHub Actions workflow or any other CI.
  • From Git — you connect a GitHub repo and pick a branch. ComputeSphere builds the image for you on every push using the Dockerfile in the repo.

Either way, what runs on the platform is the same: your container, executed with the platform's runtime environment. Image-builds keep the build pipeline in your hands; Git-builds skip the CI step.

A service in a subfolder (monorepo)​

When the service lives in a folder of a bigger repository, set root_dir in its ci_config to that folder, like apps/web. Every path is from the repository root.

  • The build runs in docker_context if you set it, otherwise in root_dir, otherwise at the repository root.
  • A bare Dockerfile is read from that folder. Any other dockerfile path is from the repository root.
  • A path with .. is refused: root_dir, docker_context and dockerfile must be paths inside the repository, from the repository root.

The CLI sets the folder with csph deployments update <deployment-id> --root-directory apps/web.

Networking​

Listen on 0.0.0.0, not localhost

Your server must bind to 0.0.0.0 on the port you set for the service — not 127.0.0.1 or localhost. The platform forwards traffic to your spherelet on that port; an app bound only to loopback is reachable from inside the spherelet but not from the platform's router, so requests fail with 502 / connection-refused even while the spherelet shows as running. Most frameworks bind to loopback by default in development — set the host explicitly for production:

  • Node / Express — app.listen(port, "0.0.0.0")
  • Python / Flask — app.run(host="0.0.0.0", port=port) (or flask run --host 0.0.0.0)
  • Gunicorn / Uvicorn — --bind 0.0.0.0:<port> / --host 0.0.0.0
  • Go — http.ListenAndServe(":"+port, ...) — the empty host already binds all interfaces
  • Default URL. Every web service gets a stable *.computesphere.app subdomain (e.g. silver-cobra.computesphere.app) the moment it's created. TLS is provisioned automatically.
  • Custom domain. Bring your own — api.example.com, app.mycompany.io. TLS certs auto-renew. See Custom domains.
  • Private network. Inside the environment, services can reach each other by service name (http://api, http://worker:9000) once private network is enabled on the environment. The public URL is unchanged either way. See Private network.

Getting the client IP​

Requests reach your app through our gateway, so the connection your app sees comes from the gateway, not the visitor. Out of the box most frameworks log that address for every request.

Every request to your service carries the visitor's address in CS-Connecting-IP, set by ComputeSphere on each request; a value sent by the client is replaced. X-Forwarded-For, X-Real-IP and True-Client-IP carry the same single address. Read CS-Connecting-IP and trust no other client-IP header.

// Express
const clientIp = (req) => req.get("cs-connecting-ip") ?? req.socket.remoteAddress;
# FastAPI / Starlette
client_ip = request.headers.get("cs-connecting-ip") or (request.client.host if request.client else None)

# Django
client_ip = request.META.get("HTTP_CS_CONNECTING_IP") or request.META["REMOTE_ADDR"]
# Rails
client_ip = request.headers["CS-Connecting-IP"] || request.remote_ip
// Go
ip := r.Header.Get("CS-Connecting-IP")
if ip == "" {
ip, _, _ = net.SplitHostPort(r.RemoteAddr)
}

The fallback covers requests that don't come through our gateway: local development, and calls from your other services over the private network. Over the private network, CS-Connecting-IP is whatever the calling service sends, so don't use it for access decisions on internal calls.

Other headers that carry the client IP​

ComputeSphere sets these to the same address, so frameworks that read them see the visitor:

  • X-Forwarded-For — holds only the visitor's address. In Express, app.set("trust proxy", 1) makes req.ip the visitor. With Uvicorn, read CS-Connecting-IP as above.
  • X-Real-IP and True-Client-IP — set by our gateway to the same address; prefer CS-Connecting-IP.

Our gateway removes any Forwarded header the visitor sends; use CS-Connecting-IP.

Apps see https in X-Forwarded-Proto: plain-HTTP requests are redirected to HTTPS before they reach your service.

This is the same on the *.computesphere.app address and on custom domains, including wildcard domains and one domain per tenant.

Health checks​

Set a health check path (e.g. /health) and the platform uses it to gate rollouts. New spherelets only take traffic once they return 200. Old spherelets keep serving until then — that's how zero-downtime deploys actually work.

Without a health check the rollout assumes "container started → ready," which is fine for short-startup apps but skips the safety net for slow-boot frameworks (Rails, Spring, Django with heavy startup). See Health checks.

Scaling​

Two ways to size a web service:

  • Manual. Pick a count, traffic load-balances across that many spherelets. Adjust any time without a redeploy.
  • Autoscaling. Set a min/max and a CPU target (e.g. 80%). The platform adds spherelets when sustained CPU climbs past the target and removes them when it settles down.

Both bounded by your account capacity. See Spherelets and Auto-scaling.

Lifecycle controls​

A web service supports every lifecycle verb — deploy, redeploy, restart, stop, start, rollback, and scale. See Service actions for what each one does, what it preserves, and when to reach for it.

Create a web service​

  1. Open the project and environment where the service should run.
  2. Click New service → Web service.
  3. Pick a build source: Image or Git.
    • For Image, paste the image path (e.g. ghcr.io/acme/api:1.0.0).
    • For Git, connect a GitHub account if you haven't, then pick a repo and branch.
  4. Fill in name, port, and a spherelet size (for example Flex 512 MB, Standard 1 or Standard 2).
  5. (Optional) Add environment variables and secrets, set a health check path, turn on autoscaling.
  6. Click Create.

The service appears in the Services tab. The first deploy starts immediately; you'll see status transitions and the live URL when it finishes.

Outputs​

When a web service is running, the platform surfaces two URLs:

OutputWhere it points
Public URLhttps://<subdomain>.computesphere.app (and any custom domains you've attached). What the world reaches.
Internal URLReachable from other services in the same environment when private network is on. Format: http://<service-name> on the service's port.

Honest limits​

  • Port is required. A web service exposes exactly one container port. For multi-port apps (e.g. an HTTP server + a metrics server), front them with a single reverse proxy or run each as its own service.
  • One image per service. Multi-container patterns (sidecars, init containers) aren't exposed today. Run the second container as a separate web service or background worker.
  • HTTP/HTTPS only. Custom protocols (raw TCP, WebSockets-over-TCP, UDP) aren't supported at the edge. WebSockets over HTTPS work — the platform terminates TLS and passes the upgraded connection through.
  • Region comes from the environment. A service runs in its environment's region; you can't place one service in a different region from the rest of its environment.

What's next​

  • Background worker — the service kind for continuous workers with no public URL.
  • Cron jobs — the service kind for scheduled, exit-when-done work.
  • Spherelets — how the compute behind your service is sized and billed.
  • Custom domains — bring your own hostname.
  • Health checks — gate rollouts on real readiness.