SignalR in ASP.NET Core behind Nginx

前端 未结 2 1381
感情败类
感情败类 2021-01-01 16:35

I have a server with ubuntu 16.04, kestrel and nginx as a proxy server that redirects to localhost where my app is. And my app is on Asp.Net Core 2. I\'m trying to add push

2条回答
  •  北海茫月
    2021-01-01 17:10

    I was able to solve this by using $http_connection instead of keep-alive or upgrade

    server {
      server_name example.com;
    
      location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
      }
    }
    

    I did this because SignalR was also trying to use POST and GET requests to my hubs, so doing just an Upgrade to the connection in a separate server configuration wasn't enough.

提交回复
热议问题