I am trying to make a website that would have http functions including http post functions, and also web sockets (such as signalR). I am trying to host this website on an ubuntu
Here is my configuration for .Net Core API with nginx:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
The main idea are remove these lines (if you have)
proxy_set_header Connection "upgrade";
proxy_set_header Connection keep-alive;
and insert this line in your configuration
proxy_set_header Connection $http_connection;
Hope it helps.
using $http_connection instead of keep-alive or upgrade
proxy_set_header Connection $http_connection;
This is not a fix to your question, but may be a workaround. I got around this by setting up 2 proxy locations in nginx to a single asp.net core kestrel site. One for the websockets with the
proxy_cache_bypass $http_upgrade;
and one for everything else. Looks like this. Top one is for all but websockets, bottom is for websockets. Note I have rewrites also.
location /n/ {
proxy_pass http://localhost:5001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
}
location /nsock/ {
proxy_pass http://localhost:5001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}