Put this in your main nginx.conf file under the http section:
map $http\_connection $connection\_upgrade {
"\~\*Upgrade" $http\_connection;
default keep-alive;
}
Then, in your site conf file use this for your hub location(s):
location /signalr-chat {
proxy_pass http://x.x.x.x:port;
# Configuration for WebSockets.$http_upgrade, $connection_upgrade is mapped in main server conf file.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache off;
# 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;
proxy_set_header Accept-Language $http_accept_language; # Optional
}
location /signalr {
proxy_pass http://x.x.x.x:port;
# Configuration for WebSockets.$http_upgrade, $connection_upgrade is mapped in main server conf file.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_cache off;
# 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;
proxy_set_header Accept-Language $http_accept_language; # Optional
}
The CORS error message can be a bit of a red herring if the proxy config is not quite right. Note that this is direct from Microsoft's config site on Nginx -> https://docs.microsoft.com/en-us/aspnet/core/signalr/scale?view=aspnetcore-5.0
Cheers.