当前位置:   article > 正文

nginx配置ws_nginx ws配置

nginx ws配置
前言

nginx支持ws协议的配置

配置
map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream BackendIotWs {
    server 10.0.0.110:7004 weight=1;
}

server {

	listen          80;
    server_name     ws.iot.com;

	location / {
		try_files $uri $uri/  /index.html last;
		root   "/usr/local/openresty/nginx/std/manage/";
        index  index.html index.htm;
	}

	location /ws/iot {
        proxy_pass http://BackendIotWs
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 3600s;
        proxy_connect_timeout 86400;
        proxy_ignore_client_abort on;
	}

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
测试
  • 访问地址:ws://ws.iot.com/ws/iot
  • 测试地址:http://coolaf.com/tool/chattest,测试正常结果,如下所示

在这里插入图片描述

结语

测试ws访问的地址

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/733220
推荐阅读
相关标签
  

闽ICP备14008679号