Skip to content

Multiple connections to _blazor #51299

@Alerinos

Description

@Alerinos

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have Blazor Web with cloudflare and nginx, if I use MapWhen it gets continuous connections only in routing /manager, the first entry breaks the connection by which pops up reconnect. The problem occurs only on the server and cloudflare. When using localhost everything is fine. Other subsites that are not in manager work fine.

image

    public static IApplicationBuilder UseManager(this WebApplication builder)
    {
        builder.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/manager"), app =>
        {
            app.UsePathBase("/manager/");
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAntiforgery();
            app.UseEndpoints(endpoints =>
            {
                var assembly = AssemblyProvider.Types<IAreaManager>().ToArray();

                endpoints.MapControllers();
                endpoints.MapRazorComponents<Areas.Manager.App>()
                    .AddInteractiveServerRenderMode()
                    .AddInteractiveWebAssemblyRenderMode()
                    .AddAdditionalAssemblies(assembly);
            });
        });

        return builder;
    }

Nginx config:

upstream ZonitService {
    server 127.0.0.1:5001;
}

upstream ZonitDashboardService {
    server 127.0.0.1:5021;
}


server {
    server_name _;

	listen                    443 ssl http2;
	listen                    [::]:443 ssl http2;
    ssl_certificate           /etc/ssl/$domain.pem;
    ssl_certificate_key       /etc/ssl/$domain.key;
	ssl_session_timeout       1d;
	ssl_protocols             TLSv1.2 TLSv1.3;
	ssl_prefer_server_ciphers off;
	ssl_ciphers               ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
	ssl_session_cache         shared:SSL:10m;
	ssl_session_tickets       off;
	ssl_stapling              off;

	add_header X-Frame-Options DENY;
	add_header X-Content-Type-Options nosniff;

	client_max_body_size 32M;

	location / {
		proxy_pass http://ZonitService;
		limit_req  zone=one burst=10 nodelay;
		proxy_redirect          off;
		proxy_set_header        Host $host;
		proxy_set_header        X-Real-IP $remote_addr;
		proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header        X-Forwarded-Proto $scheme;
		client_max_body_size    10m;
		client_body_buffer_size 128k;
		proxy_connect_timeout   90;
		proxy_send_timeout      90;
		proxy_read_timeout      90;
		proxy_buffers           32 4k;
	}
	
	location /_blazor {
		proxy_pass http://ZonitService;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection $connection_upgrade;
		proxy_cache off;
		proxy_http_version 1.1;
		proxy_buffering off;
		proxy_read_timeout 100s;
		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
    }
}

It seems to me that the problem occurs through Server Sider Rendering.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

.net 8 rc 2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions