Communication with the Runtime
Communication with the spin runtime is done via a websocket connection from the browser. The runtime does not need to be reachable by the SPIN’s cloud hosted control plane. For more information see our architecture docs. When adding a new runtime via the SPIN UI, you have to specify the URL of the runtime. When sharing a runtime across your team, you will need to host the runtime in a way that is reachable by all those members. Making it accessible from the internet via a public URL is an option. Constraining access to the runtime via a VPN (such as Tailscale) or an SSH tunnel is another option that can enhance security.Note that for runtimes not running on the users machine directly
require a secure connection via HTTPS with a valid certificate.
This is because the browser will not allow the runtime to connect to a non-secure origin unless the origin is
localhost
.
See Enabling HTTPS for the Runtime for detailed instructions on how to configure SSL certificates.Deploy in Your Own Infrastructure
A Docker image is available for deployment in your own environment:Docker
Run the runtime as a standalone container:Docker Compose
Example configuration for Docker Compose:compose.yml
Set up with Tailscale
With Tailscale you can access the SPIN runtime without exposing it to the public internet.
See how to configure SPIN runtime with Tailscale sidecar in Docker Compose.
Set up with Cloudflare Tunnels
With Cloudflare Tunnels you can access the SPIN runtime without exposing it to the public internet.
See how to configure SPIN runtime with Cloudflare Tunnels in Docker Compose.
Kubernetes
TODO: Add instructions for deploying in Kubernetes.Upgrading the Runtime
When new versions of the SPIN runtime are released, you’ll need to update your deployment to use the latest image.Docker
For standalone Docker containers:Docker Compose
For Docker Compose deployments, upgrading is simpler:- Pull the latest version of the image
- Recreate containers if the image has changed
- Preserve your volumes and configuration
Cloud-Hosted Runtime
For testing, you can spin up a cloud-hosted runtime with a few clicks. This is great for experimentation, but for production use, we recommend self-hosting.Configuration
Configure the SPIN runtime using these environment variables:Variable | Description |
---|---|
SPIN_TOKEN | Required. Secure token for authenticating connections to the runtime. Must match the token provided when adding the runtime to your workspace. |
SPIN_HOME | Optional. Base directory for SPIN runtime files. Defaults to /opt/spin. |
REQUESTS_CA_BUNDLE | Optional. Path to a CA certificate bundle file or directory for SSL verification. When not set, SSL certificate validation is disabled for outbound requests from the runtime. Set this to enforce SSL verification. |
<your-env-var-name> | Optional. Any other environment variable can be passed to the runtime. Refer to them using the {{runtime_env:<your-env-var-name>}} syntax. |
Enabling HTTPS for the Runtime
By default, the SPIN runtime serves connections over HTTP. For production deployments where the runtime is accessed over the network (not localhost), you’ll need to serve it over HTTPS. There are several ways to achieve this:- Enable HTTPS directly on the runtime (covered in this section)
- Use a reverse proxy (like nginx or Apache) that terminates SSL
- Use a gateway or load balancer that handles SSL termination
- Use a tunnel solution like Cloudflare Tunnels or Tailscale
What You’ll Need
To enable HTTPS, you need:- SSL Certificate (
cert.pem
): This is your public certificate file that proves the identity of your server - Private Key (
key.pem
): This is the private key that corresponds to your certificate
Docker
To run the runtime with HTTPS enabled:./path/to/key.pem
and./path/to/cert.pem
with the actual paths to your SSL files<YOUR-GENERATED-TOKEN>
with the actual SPIN_TOKEN from UI Add Runtime flow
Docker Compose
For Docker Compose, add the SSL configuration to your service:compose.yml
When HTTPS is enabled, the runtime will serve connections using TLS encryption. Make sure to update your runtime URL in the SPIN UI to use
https://
instead of http://
.- The
:ro
suffix on volume mounts makes the certificates read-only, which is a security best practice - Keep your private key (
key.pem
) secure and never commit it to version control - Never share or commit your SPIN_TOKEN - treat it like a password
- Ensure your certificate is valid for the domain/hostname you’re using to access the runtime
SSL Certificate Validation
By default, the SPIN runtime disables SSL certificate validation for outbound HTTPS requests to external services (e.g., APIs, data sources). This behavior helps avoid issues with self-signed certificates or internal certificate authorities in enterprise environments. To enable SSL certificate validation, set theREQUESTS_CA_BUNDLE
environment variable. This can point to either:
- A single certificate bundle file (e.g.,
/etc/ssl/certs/ca-bundle.crt
) - A directory containing multiple certificates (e.g.,
/etc/ssl/certs/
)
When using a directory, it must be prepared using the
c_rehash
utility supplied with OpenSSL. This creates symbolic links with hashed filenames that allow efficient certificate lookup.Example of preparing a certificate directory:-
For Docker: Mount your CA certificates and set the environment variable.
Using a certificate bundle file:
Using a certificate directory (must be processed with c_rehash):
-
For Docker Compose: Add the certificate volume and environment variable.
Using a certificate bundle file:
Using a certificate directory:compose.ymlcompose.yml
When
REQUESTS_CA_BUNDLE
is not set, the runtime will accept any SSL certificate. This may pose security risks in production environments. Consider enabling SSL verification for production deployments.