aspnetcore: Blazor 8 reverse proxy signin-oidc not working.

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I’m trying to get blazor 8 signin to work behind my nginx reverse proxy. Everything works but the signin. It comes back with 404 not found. Everything works fine on local host and if I make the application work on the root of the domain it works to.

I have added all of the Forwarded Headers from the documentation to my programs.cs and my application configuration in nginx.

I have updated the call back path in appsettings.json

I tried adding a page options route and that didn’t help.

builder.Services.AddRazorPages()
    .AddRazorPagesOptions(options =>
    {
        options.Conventions.AddPageRoute("/app1/signin-oidc", "/signin-oidc");
    });

My sign uses Azure Ad.

Here is basic layout of my domain setup.

https://apps.example.com (nginx reverse proxy)
https://apps.exmaple.com/apps1/ (first blazor application)
https://apps.example.com/apps2/ (second blazor application)

If I set the location for app1 to work on / then everything works fine.

I’m unsure if I need to do something different to make the page route or if I’m missing a configuration altogether.

I love many of the new changes in Blazor 8, but so much of it has been very frustrating to the point that I’m learning it all over again.

Expected Behavior

blazor application accepts /app1/signin-oidc and not give a 404.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

8.0…1

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Same problem, I’ve spent a week looking into this…

Everything works fine in localhost and breaks behind a proxy using http.

I’m using Keycloak.

Browser Server

  • Nginx – MyAppDocker – KeycloakDocker

Open a new incognito tab. Enter the https://mydomain.com/. Everything works fine, the blazor is using websokets Go to a page with [Authorize] like https://mydomain.com/private I’m redirected to login, then redirected to the /singin-oidc Then I get my cookie but websokets stop working and Blazor swiches to longpooling Somwhere in the logs Antiforgery token could not be validated.

The antiforgery token could not be decrypted. The key was not found in the key ring.

The site works well if I dont go to protected pages but switches to longpooling. Also this only affects the /_blazor request for some reason.

So please, reopen this issue

Maybe this is related: #51929 (comment)

Sure looks close to the same type of issue I’m having.

My project was like a 2 or 3 day project that now becoming 3 week project for something that was going to be simple.