nginx 添加websocket

修改nginx.conf文件

 http模块添加

map_hash_bucket_size    64; 在map变量之前
map $http_upgrade $connection_upgrade {
    default upgrade;
    ‘‘ close;
    }

  server模块添加

server {
                server_name ******;
                listen 443 ssl http2;

                ssl_certificate          ssl/******.pem;
                ssl_certificate_key     ssl/*****.key;

                location / {
                        proxy_pass https://upstream-test;

                }
                location /ws {
                        proxy_pass https://upstream-test;

                        proxy_read_timeout 300s;
                        proxy_send_timeout 300s;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "Upgrade";
                }
upstream upstream-test {
               server    IP:PORT;  
}

  

nginx 添加websocket

上一篇:动态粒子效果 html+js


下一篇:Nest.js