3

I have a blazor-server application, which works correctly in all cases other than running behind reverse proxy (I've only tested with NGINX).

Browser is able to connect to /_blazor?id=xyz endpoint and successfully send/receive heartbeat messages. But events with button click etc. does not work at all. There are no error or warnings in console and application's logs.

Nginx config is written according to this .NET docs
Here is my setup:

map $http_connection $connection_upgrade {
    "~*Upgrade" $http_connection;
    default keep-alive;
}

server {
  listen 80;
  server_name service.example.com;

  location / {
    # App server url
    proxy_pass http://localhost:9000;

    # Configuration for WebSockets
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_cache off;
    # WebSockets were implemented after http/1.0
    proxy_http_version 1.1;

    # Configuration for ServerSentEvents
    # proxy_buffering off; # Removed according to docs

    # Configuration for LongPolling or if your KeepAliveInterval is longer than 60 seconds
    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;
  }
}

I think the problem is because of nginx, as app works fine on my local machine.

If you need any more data, please comment below, I will provide.

Thanks in advance.

Alvan Rahimli
  • 348
  • 4
  • 10

1 Answers1

3

Apparently, cloudflare was also configured to proxy my request, and this somehow affected it.

Disabling cloudflare proxy and configuring https with let's encrypt solved the issue

Alvan Rahimli
  • 348
  • 4
  • 10
  • After some research, I saw people using nginx+cloudflare(free) with almost same config. I'll keep this one updated as I get answers. – Alvan Rahimli Sep 17 '22 at 19:25