国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

ssl - websocket請求nginx監聽的端口,出現WebSocket opening handshake was canceled

瀏覽:114日期:2023-08-19 10:40:00

問題描述

nginx版本是1.10.1

nginx配置tcp轉發:

tcp{ upstream ge_ssl { server 127.0.0.1:1234; } map $http_upgrade $connection_upgrade{ default upgrade; ’’ close; }server{ listen 9988; ssl on; ssl_certificate /etc/le/l/abc.com/fullchain.pem; ssl_certificate_key /etc/le/l/abc.com/privkey.pem; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass http://ge_ssl; proxy_http_version 1.1; #proxy_ssl_session_reuse off; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; } } }

nginx監聽端口:443,80,9988

443:ssl證書 80:rewrite 跳轉4439988:該端口為了應對網頁的websocket請求,然后將請求轉發給1234端口

瀏覽器:FireFox,Chrome

網頁代碼:

var ws = new WebSocket(’ws://129.136.145.58:9988’); 在FireFox上面,可以通過,Chrome上面,會出錯,錯誤如下: Mixed Content: The page at ’https://www.abc.com/me’ was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ’ws://129.136.145.58:9988/’. This request has been blocked; this endpoint must be available over WSS. Uncaught SecurityError: Failed to construct ’WebSocket’: An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.所以網頁代碼改用為var ws = new WebSocket(’wss://129.136.145.58:9988’);這下FireFox和Chrome一起失敗了...錯誤如下: WebSocket connection to ’wss://129.136.145.58:9988/’ failed: WebSocket opening handshake was canceled

查了好多資料都不知道為啥,求大神指點一二,感激不盡。。。

問題解答

回答1:

https和ws不能混用,用http和wss

標簽: web
主站蜘蛛池模板: 四会市| 卫辉市| 周宁县| 年辖:市辖区| 阿克陶县| 蛟河市| 遵义县| 连州市| 卢湾区| 沙雅县| 澄城县| 阿图什市| 香港| 宁夏| 阳泉市| 丰都县| 措勤县| 新竹县| 湖北省| 沂南县| 兴隆县| 南丹县| 无为县| 武穴市| 锡林浩特市| 邵武市| 始兴县| 南江县| 包头市| 安义县| 尖扎县| 哈密市| 兴安县| 蒙山县| 关岭| 丘北县| 广安市| 南昌市| 普安县| 内乡县| 西贡区|