惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
小众软件
小众软件
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
博客园_首页
G
Google Developers Blog

博客园 - cnkker.com

Visual Studio 2026 激活码 / VS2026密钥(VS2026激活码) 沙箱环境安装dotnet Microsoft Office 2024 全家桶 docker-compose 部署 Redis 的一些警告 UFW防火墙规则对Docker映射端口无效 Nginx错误 open() "/usr/local/nginx/proxy_temp/x/xx/xxxxxxxx" failed (13: Permission denied) while reading upstream解决办法 NET8在CentOS7下无法执行的问题 Error: Failed to download metadata for repo ‘appstream’ – CentOS 8 Mikrotik ROS默认推荐防火墙规则firewall脚本 dotnet堆栈溢出通用排查方法 CMD下查所有3389连接的IP地址 Nginx的proxy_pass url 反向代理的配置 一些名词 NET CORE LINUX 部署 报 A connection was successfully established with the server, but then an error occurred during the pre-login handshake.解决方法 须先停止生成方可关闭解决方案(The build must be stopped before the solution can be closed) 安装最新版本NextCloud Docker、Nginx、整合LetsEncrypt SSL证书 如何将 Windows 10 Enterprise LTSC 2021 评估版升级到完整版 MS SQL 去除字段中的大小写英文、数字、特定符号 MariaDB 配置示例文件 整理一些激活密钥
Nginx配置文件中,如何配置启用SignalR
cnkker.com · 2023-10-11 · via 博客园 - cnkker.com

以下内容包含为 SignalR 启用 WebSocket、ServerSentEvents 和 LongPolling 所需的最低设置:

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

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

    # Configure the SignalR Endpoint
    location /hubroute {
      # App server url
      proxy_pass http://localhost:5000;

      # 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;

      # 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;
    }
  }
}

使用多个后端服务器时,必须添加粘滞会话(sticky sessions),以防止 SignalR 连接在连接时切换服务器。 可通过多种方法在 Nginx 中添加粘滞会话(sticky sessions)。 下面是其中一种

除了前面的配置外,还添加了以下内容。 在下面的示例中,backend 是服务器组的名称。

对于 Nginx 开放源代码,使用 ip_hash 基于客户端的 IP 地址将连接路由到服务器:(必须是ip_hash 

http {
  upstream backend {
    # App server 1
    server localhost:5000;
    # App server 2
    server localhost:5002;

    ip_hash;
  }
}

最后,将 server 部分中的 proxy_pass http://localhost:5000 更改为 proxy_pass http://backend