1.http中配置 $connection_upgrade 否则报错
http { map $http_upgrade $connection_upgrade { default upgrade; '' close; } }
2.具体配置部分:
location /message { proxy_pass http://127.0.0.1:8100; 需要代理的后端ip proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; }