Skip to content

Commit ad035df

Browse files
renemadsenclaude
andcommitted
Add dual-port Kestrel config for gRPC HTTP/2 support
Port 5000 serves REST (HTTP/1.1+2), port 5001 serves gRPC with HTTP/2-only (h2c) so Traefik can forward gRPC traffic correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f02efe commit ad035df

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

eFormAPI/eFormAPI.Web/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,17 @@ private static IHost BuildWebHost(string[] args)
486486
webBuilder.ConfigureKestrel(serverOptions =>
487487
{
488488
serverOptions.Limits.MaxRequestBodySize = 100 * 1024 * 1024;// 100Mb
489-
serverOptions.ConfigureEndpointDefaults(listenOptions =>
489+
// REST + web: HTTP/1.1 and HTTP/2
490+
serverOptions.ListenAnyIP(int.Parse(port), listenOptions =>
490491
{
491492
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http1AndHttp2;
492493
});
494+
// gRPC: HTTP/2 only (h2c — cleartext HTTP/2)
495+
serverOptions.ListenAnyIP(int.Parse(port) + 1, listenOptions =>
496+
{
497+
listenOptions.Protocols = Microsoft.AspNetCore.Server.Kestrel.Core.HttpProtocols.Http2;
498+
});
493499
})
494-
.UseUrls($"http://0.0.0.0:{port}")
495500
// .UseIISIntegration()
496501
.ConfigureAppConfiguration((hostContext, config) =>
497502
{

0 commit comments

Comments
 (0)