Service Primitives
Services
HTTPS entrypoints that route hosts and paths to deployments.
A service is how HTTP traffic from the internet reaches your deployments. The Unisrv edge terminates TLS, then routes each request by path prefix to a deployment or proxies it to an external URL.
A request for /api/users arrives at a service over HTTPS. The service checks its locations in order: /api/admin does not match, /api does, so the request goes to the api deployment and the remaining locations are never checked.
Every service gets {service}-{slug}.unisrv.dev for free, where the slug comes from its environment.
Custom domains
- Claim the domain with
unisrv host claimor from Hosts in the web console. Both show the DNS records to create. - Create the records at your DNS provider. Unisrv issues a Let's Encrypt certificate once they resolve.
- Add the domain to the service's
hosts.
Names under unisrv.dev need no DNS. unisrv up claims them for you.
Things to know
- HTTP only, for now. Services are L7. Raw TCP and UDP need a dedicated IP per service, which isn't supported yet. For traffic between deployments, use an internal network.
- HTTPS by default. Plain HTTP redirects unless you set
allow_http. - Unreachable instances are skipped. If the edge can't connect to an instance, it sends the request to another one. A request the instance may already have received is only retried when its method is idempotent, such as
GET. - SPAs can set
override_404 = "/index.html"to serve the app for unknown paths.
CLI HCL reference: service.