From 28a55246df42863754d325312fa92935721fafdf Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Thu, 14 May 2026 00:36:54 +0330 Subject: [PATCH] chore: update gateway URL configuration for staging environment - Changed GW_URL and GwUrl in frontoffice-deployment.yaml and Dockerfile to use the internal service URL http://cms-svc:8080 for the staging environment. - Enhanced ConfigureServices to handle HTTP/1.1 for gRPC when using the internal service URL, ensuring compatibility with Kestrel's requirements. --- k8s/staging/frontoffice-deployment.yaml | 4 ++-- src/FrontOffice.Main/ConfigureServices.cs | 26 +++++++++++++++++------ src/FrontOffice.Main/Dockerfile | 2 ++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/k8s/staging/frontoffice-deployment.yaml b/k8s/staging/frontoffice-deployment.yaml index 88b5cf3..30879bb 100644 --- a/k8s/staging/frontoffice-deployment.yaml +++ b/k8s/staging/frontoffice-deployment.yaml @@ -29,9 +29,9 @@ spec: - name: ASPNETCORE_ENVIRONMENT value: "Staging" - name: GW_URL - value: "https://cms.se.kbs1.ir" + value: "http://cms-svc:8080" - name: GwUrl - value: "https://cms.se.kbs1.ir" + value: "http://cms-svc:8080" resources: requests: memory: "256Mi" diff --git a/src/FrontOffice.Main/ConfigureServices.cs b/src/FrontOffice.Main/ConfigureServices.cs index e26f7b2..4e60d8a 100644 --- a/src/FrontOffice.Main/ConfigureServices.cs +++ b/src/FrontOffice.Main/ConfigureServices.cs @@ -103,16 +103,28 @@ public static class ConfigureServices var baseUrl = ResolveGatewayUrl(configuration) ?? throw new InvalidOperationException("Gateway URL is missing. Set GW_URL or GwUrl."); - // Register optimized HttpClient for gRPC + var isHttp = baseUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase); + + // When the base URL is plain HTTP (e.g. in-cluster http://cms-svc:8080), we must force HTTP/1.1 + // so that GrpcChannel does not upgrade to h2c and trigger HTTP_1_1_REQUIRED from Kestrel. + // For HTTPS the default negotiation is fine. services.AddScoped(sp => { - var handler = new HttpClientHandler - { - MaxConnectionsPerServer = 10, - AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate - }; + HttpMessageHandler inner = isHttp + ? new SocketsHttpHandler + { + MaxConnectionsPerServer = 10, + AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate, + DefaultRequestVersion = System.Net.HttpVersion.Version11, + DefaultVersionPolicy = System.Net.Http.HttpVersionPolicy.RequestVersionExact + } + : new HttpClientHandler + { + MaxConnectionsPerServer = 10, + AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate + }; - return new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, handler)) + return new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, inner)) { Timeout = TimeSpan.FromMinutes(10), BaseAddress = new Uri(baseUrl) diff --git a/src/FrontOffice.Main/Dockerfile b/src/FrontOffice.Main/Dockerfile index e6c235e..b548502 100644 --- a/src/FrontOffice.Main/Dockerfile +++ b/src/FrontOffice.Main/Dockerfile @@ -22,6 +22,8 @@ COPY --from=build /app/publish . ENV ASPNETCORE_URLS=http://+:80 ENV GW_URL=https://cms.se.kbs1.ir +# For Kubernetes staging, override GW_URL/GwUrl to http://cms-svc:8080 via deployment env vars +# to avoid TLS PartialChain when the public ingress cert is not trusted by the container. EXPOSE 80 ENTRYPOINT ["dotnet", "FrontOffice.Main.dll"]