Reverse Proxy returning 502 on requests to app service using client certificate authentication #895
-
We are using YARP to redirect traffic from a web application in Azure to an app service in Azure that uses MTLS authentication. The error received is 502 ( bad gateway). var routes = new[]
{
new ProxyRoute()
{
RouteId = "route1",
ClusterId = "cluster1",
Match = new ProxyMatch
{
Path = "/api/{*any}"
}
}
};
var serviceUrl= Configuration["serviceUrl"];
var cert = GetClientCertificate();
var clusters = new[]
{
new Cluster()
{
Id = "cluster1",
SessionAffinity = new SessionAffinityOptions { Enabled = true, Mode = "Cookie" },
Destinations = new Dictionary<string, Destination>(StringComparer.OrdinalIgnoreCase)
{
{ "destination1", new Destination() { Address = serviceurl} }
},
HttpClient = new ProxyHttpClientOptions { ClientCertificate = cert, MaxConnectionsPerServer = 10, SslProtocols = SslProtocols.Tls12 }
}
};
services.AddReverseProxy()
.LoadFromMemory(routes, clusters);
**In Configure:**
app.UseEndpoints(endpoints =>
{
endpoints.MapReverseProxy();
}); The destination service has Client certificate mode turned on to Required and the validation of the cert is done in the x-arr-clientcert header of the request. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
First you'll want to capture the server logs to see what the full error was. |
Beta Was this translation helpful? Give feedback.
First you'll want to capture the server logs to see what the full error was.
https://github.com/microsoft/reverse-proxy/blob/c3c0407b613286734cfb9d37102a933840a7f2d1/samples/ReverseProxy.Config.Sample/appsettings.json#L7-L13
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-5.0#configure-logging