Nginx反向代理Asp.Net Core并开启WebSocket


#user  nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  2048;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

     map $http_upgrade $connection_upgrade {
	    default upgrade;
	    ''      close;
	}
	server {
	    listen   90;
	    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   Connection $connection_upgrade;
		        proxy_set_header   Host $host;
		        proxy_cache_bypass $http_upgrade;
		        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
		        proxy_set_header   X-Forwarded-Proto $scheme;
	    }
	  }
}