Skip to main content

Prerequisites

  • A deployed CVM on Phala Cloud
  • Docker image with gRPC service
  • gRPC client tools for testing
This guide shows you how to deploy gRPC services with native HTTP/2 support and automatic TLS encryption.

How gRPC Works Through the Gateway

gRPC services get special HTTP/2 treatment:
  1. Add a g suffix to your port: <app-id>-<port>g.<cluster>.phala.network
  2. Gateway detects the g suffix and enables HTTP/2 via ALPN negotiation
  3. gRPC traffic flows over HTTP/2 with automatic TLS termination
  4. Your service handles standard gRPC calls without TLS configuration
Note: The g suffix enables HTTP/2 for any service, not just gRPC. You can use it for any HTTP/2-compatible application that benefits from multiplexing, server push, or header compression.

Deploy Your gRPC Service

Access your gRPC service at: <app-id>-50051g.dstack-prod5.phala.network:443 Note the g suffix - this tells the gateway to enable HTTP/2.

Connect from Clients

gRPC with Custom Domains

Use dstack-ingress for custom domains:
Then connect to: api.mycompany.com. Learn more details at Set up custom domains. dstack-ingress terminates TLS and forwards raw TCP to the backend. For gRPC custom domains, set ALPN=h2 so clients can negotiate HTTP/2 over TLS; your backend should accept cleartext HTTP/2 on TARGET_ENDPOINT.

Testing with grpcurl

Key Differences

gRPC (with g suffix):
  • Native HTTP/2 with ALPN negotiation
  • Optimal performance for gRPC protocols
  • Proper streaming support
Regular HTTP:
  • Standard HTTP/1.1 or HTTP/2
  • Best for REST APIs and web applications
  • No gRPC-specific optimizations

Internal vs External

Troubleshooting

No HTTP/2 negotiation? Use the g suffix and verify ALPN support. Connection refused? Check port mapping and service status. TLS errors? Connect to port 443 with correct hostname.

Next Steps