2017-10-10 164 views
0

我已經在ubuntu上將Asp.Net Core 2網站與Nginx一起部署爲反向代理。該網站的作品,但SignalR沒有。在IIS-Express中本地同樣構建工作。在日誌中獲取跟蹤錯誤, 通過發送204響應來終止長輪詢連接。Asp.Net Core 2 SignalR Ubuntu Xamarin Android

繼nginx的配置,我使用,

server { 
    listen 80; 
    location/{ 
     proxy_pass http://localhost:5000; 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection keep-alive; 
     proxy_set_header Host $host; 
     proxy_cache_bypass $http_upgrade; 
    } 
} 

我訪問來自Xamarin的Android服務器。 可能是什麼問題?任何幫助都會很棒。提前致謝。

+0

嘗試'proxy_set_header連接「升級」'; –

+0

謝謝。如果我這樣做,我的POST-API不起作用。我會盡力而爲。 –

+0

您可能需要它在一個特定的URL位置,而不是整個'/' –

回答

0

你應該改變你的配置要添加哪些需要升級頭附加路徑

server { 
    listen 80; 
    location/{ 
     proxy_pass http://localhost:5000; 
     proxy_http_version 1.1; 
     proxy_set_header Host $host; 
     proxy_cache_bypass $http_upgrade; 
    } 

    location /socket/path/ { 
     proxy_pass http://localhost:5000; 
     proxy_http_version 1.1; 
     proxy_set_header Upgrade $http_upgrade; 
     proxy_set_header Connection "Upgrade"; 
     proxy_set_header Host $host; 
     proxy_cache_bypass $http_upgrade; 
    } 
}