.net core nginx hosting sockets doesn't allow http post

后端 未结 3 1631
花落未央
花落未央 2021-01-23 01:17

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

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-23 01:35

    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.

提交回复
热议问题