Skip to main content

dstack-gateway Operational Features

The dstack-gateway component includes comprehensive operational capabilities designed to maintain robust security, automatic cleanup, and enhanced observability within dstack deployments. For automated cleanup and maintenance, the gateway continuously monitors WireGuard handshake activity to efficiently remove stale CVM instances, ensuring optimal resource usage. It proactively manages gateway node cleanup to maintain seamless synchronization across distributed clusters. WireGuard configurations are automatically updated, providing stable networking without manual intervention, and connections are systematically recycled every five minutes, enforcing a maximum timeout limit of 10 hours to preserve both security and system efficiency. Security and authorization within the gateway are rigorously enforced. It mandates remote attestation verification for CVM registration, verifying the integrity and identity of each confidential VM instance at launch. Additionally, integration with the KmsAuth contract strengthens application authorization cryptographically, guaranteeing that only legitimate deployments receive necessary keys and credentials. Active TLS certificate transparency monitoring prevents unauthorized certificate issuance, while the management of CAA records restricts certificate authorities, significantly mitigating risks associated with unauthorized or compromised certificates. For effective monitoring and observability, the gateway provides real-time tracking of connection statistics, offering immediate insights into network health and usage patterns. CVM instance health is assessed through regular WireGuard handshake checks, enabling rapid identification and resolution of potential connectivity issues. Additionally, the system monitors certificate expiration closely, issuing proactive alerts to avoid service disruptions due to expired certificates. Continuous monitoring of cluster synchronization status further ensures that distributed deployments remain reliable, coordinated, and resilient across diverse operational scenarios.

dstack-gateway Implementation

The dstack-gateway is a reverse proxy and networking component that handles TLS termination, WireGuard VPN connections, and traffic routing between external clients and Confidential Virtual Machines (CVMs). 5

Advanced Routing Configuration

The gateway uses sophisticated domain-based routing with the following patterns: 6
PatternRouting LogicTLS ModeDefault Port
<app-id>.domain.comDirect app routingTLS Termination80
<app-id>-<port>.domain.comCustom port routingTLS TerminationSpecified port
<app-id>s.domain.comTLS passthroughTLS Passthrough443
<app-id>-<port>s.domain.comCustom port with TLS passthroughTLS PassthroughSpecified port
custom.domain.comDNS TXT lookup: _dstack-app-addressTLS PassthroughFrom TXT record

Gateway Confirguation — Detailed Example

Next Steps

Now that you understand Gateway networking and TLS management, continue learning about dstack’s core components: