.netazure-container-apps

Azure Container App and OpenId Challenge not redirecting to https


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 ?


Solution

  • 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();