cloudflare下如何配置nginx支持signalr3?
How to configure nginx to support signalr3 under cloudflare?
我正在为 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
但 POST
为 404
POST proxy/notifications?id=uFQtMDg1dXib6LGvUssQhQ
请停止!
ps。我的 Hub 很简单...
[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;
}
我正在为 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;
}
}
我在这里想念什么?
当我浏览我的页面时,我收到
的 OKGET /proxy/notifications/negotiate
和
GET /proxy/notifications?id=uFQtMDg1dXib6LGvUssQhQ
但 POST
为 404POST proxy/notifications?id=uFQtMDg1dXib6LGvUssQhQ
请停止!
ps。我的 Hub 很简单...
[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;
}