我正在努力使用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;
}