1

I'm trying to setup a Blazor Server on Azure Container App. I have setup the container with ingress on HTTP port 80, added a custom domain name with managed certificate.

Everything is working fine except the OpenID connection. The redirect URI is starting with http:// instead of https://

I'm pretty sure it's because the image is using the port 80 but as soon as I set it to 443 I got an certificate missing error.

How could I pass down the certificate to the docker instance ? or should I do something else ?

Thibaud
  • 377
  • 1
  • 2
  • 15
  • Can you make sure you have the forwarded headers middleware configured https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-7.0#forwarded-headers-middleware-order The app is listening on port 80 (http), but the platform proxy is handling tls for you. You should have a header `x-forwarded-proto: https` that tells your application that its handling a forwarded https request from a trusted proxy – ahmelsayed Jul 20 '23 at 19:08
  • Thanks @ahmelsayed ! That was that :) – Thibaud Jul 23 '23 at 07:46
  • @Thibaud, Kindly post your Solution as an answer for clarity, also it will help the community. – Sourav Jul 25 '23 at 11:32

1 Answers1

1

As @ahmelsayed mentionned, I used the following configuration in my program.cs file :

var builder = WebApplication.CreateBuilder(args);

//Service registration (cut for simplicity)

builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    app.UseHsts();
}
else
{
    app.UseDeveloperExceptionPage();
}

app.UseForwardedHeaders();

//some other call not specific to the solution

app.Run();

Thibaud
  • 377
  • 1
  • 2
  • 15