首页 > Web开发 > 详细

nginx 添加websocket

时间:2021-06-08 20:35:52      阅读:32      评论:0      收藏:0      [点我收藏+]

修改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

原文:https://www.cnblogs.com/lllhr/p/14863807.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!