Open pregress opened 5 years ago
Please refer to this issue for more details. In summary it's a known limitation of the integration, it only supports certificate authentication.
I Solved it by deploy a Proxy service for the Service fabric service, that handles the authentication for us.
private const int StreamCopyBufferSize = 81920;
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// send every request to Service fabric api
app.MapWhen(ctx => true, appBuilder =>
{
appBuilder.Run(async context =>
{
var requestMessage = context.Request.ToHttpRequestMessage("localhost",19080);
try
{
var response = await Client.SendAsync(requestMessage);
using (var responseStream = await response.Content.ReadAsStreamAsync())
{
await responseStream.CopyToAsync(context.Response.Body, StreamCopyBufferSize, context.RequestAborted);
}
}
catch (Exception e)
{
await context.Response.WriteAsync(e.ToString());
context.Response.StatusCode = 500;
}
});
});
}
private static readonly HttpClient Client = new HttpClient(
new HttpClientHandler
{
UseDefaultCredentials = true,
})
{
BaseAddress = new Uri("http://localhost:19080")
};
And I changed the clustermanagementurl to the new Proxy Service Url
To build on @pregress's answer, this is now even simpler with the Microsoft.AspNetCore.Proxy
package (assuming you're using ASP.NET Core):
<PackageReference Include="Microsoft.AspNetCore.Proxy" Version="0.2" />
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.RunProxy(new ProxyOptions
{
Host = "localhost",
Port = "19080",
Scheme = "http",
BackChannelMessageHandler = new HttpClientHandler() { UseDefaultCredentials = true }
});
}
}
Do you want to request a feature or report a bug?
Bug
What did you do?
Provider connection error: Service Fabric responded with error code 401 Unauthorized to request http://localhost:19080/Applications/?api-version=3.0 with body {}; retrying in 588.391017ms
What did you expect to see?
No providers found.
What did you see instead?
Output of
traefik version
: (What version of Traefik are you using?)What is your environment & configuration (arguments, toml, provider, platform, ...)?
Part of our cluster config.
If applicable, please paste the log output in DEBUG level (
--logLevel=DEBUG
switch)