代理阻止 websockets?如何绕过 [英] Proxy blocking websockets? How to get round

查看:42
本文介绍了代理阻止 websockets?如何绕过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 Python 编写的 websocket 服务器,(来自 https://github.com/opiate/SimpleWebSocketServer),当我尝试从我家连接到它时,它工作正常.但是,当我尝试从学校连接到它时,那里有一个网络代理,但连接失败并显示错误未定义".

I have a websocket server running written in Python, (from https://github.com/opiate/SimpleWebSocketServer), and when I try to connect to it from my house, it works fine. However, when I try to connect to it from school, where there is a web proxy in place, it fails to connect with the error "undefined".

我相信是代理停止了连接,但我不确定如何测试以查看它是否确实如此.我如何测试这个,如果是代理,我该如何解决这个问题?

I believe that it is the proxy that is stopping the connection, but am not sure how to test to see if it definitely is. How can I test this, and if it is the proxy, how can I get round this?

谢谢

推荐答案

许多代理服务器将 HTTP 请求的标头替换为自己的标头.他们将删除他们不理解的任何标头,因此当代理不支持 websocket 时,它将阻止任何 websocket 握手工作.

Many proxy servers replace the headers of HTTP requests with their own. They will remove any headers they don't understand, so when the proxy doesn't support websocket yet it will prevent any websocket handshake from working.

作为一种解决方法,您可以为您的网站获取 TLS 证书并使用 https 和 wss.这会加密标头,从而防止代理弄乱它们.

As a workaround you can get a TLS certificate for your website and use https and wss. This encrypts the headers and thus prevents the proxy from messing with them.

顺便说一句:无论如何你都应该支持TLS.在当今世界,您不再需要使用加密的充分理由,而是需要一个不使用加密的充分理由.

这篇关于代理阻止 websockets?如何绕过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆