asp.net – 如何配置nginx以支持cloudflare下的signalr3?

前端之家收集整理的这篇文章主要介绍了asp.net – 如何配置nginx以支持cloudflare下的signalr3?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在努力使用signalr3和Nginx反向代理配置,我的Nginx cfg看起来像这样:

server {
listen       80;
server_name  my.customdomain.com;

location / {
  root /pages/my.customdomain.com;
  index index.html index.htm;
  try_files $uri $uri/ /index.html =404;
}

## send request back to kestrel ##
location /proxy/ {
 proxy_pass  http://xxxxxxxxxx.westeurope.cloudapp.azure.com/;

 proxy_set_header        Host            $host;
 proxy_set_header        X-Real-IP       $remote_addr;
 proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
 }
}

我在这里想念什么?

当我浏览我的页面时,我收到了OK

GET /proxy/notifications/negotiate 

GET /proxy/notifications?id=uFQtMDg1dXib6LGvUssQhQ

但是404用于POST

POST proxy/notifications?id=uFQtMDg1dXib6LGvUssQhQ

请停下来!

PS.我的中心很简单……

[AllowAnonymous]
public class NotificationHub : Hub
{

}
最佳答案
这是一个基于websocket的应用程序,因此您需要额外的Nginx配置

location / { 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Nginx-Proxy true; 
    #proxy_set_header X-Forwarded-Proto https; 
    proxy_pass 127.0.0.1:8080; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade";
    proxy_ssl_session_reuse off; 
    proxy_set_header Host $http_host; 
    proxy_cache_bypass $http_upgrade; 
    proxy_redirect off; 
}
原文链接:https://www.f2er.com/nginx/434410.html

猜你在找的Nginx相关文章