简体   繁体   English

WebSocket over SSL:Cloudflare

[英]WebSocket over SSL: Cloudflare

I have a website behind cloudflare. 我在cloudflare后面有一个网站。 I need to enable websockets over SSL without turning off cloudflare support. 我需要通过SSL启用websockets而不关闭cloudflare支持。 I have a PRO plan and hence won't get the new websocket support. 我有一个PRO计划,因此不会获得新的websocket支持。 I am using Nginx to proxy a SSL connection to a web socket running on a node server. 我正在使用Nginx代理SSL连接到节点服务器上运行的Web套接字。 Now, I read somewhere that cloudflare could work with approved ports would support websockets. 现在,我读到某个地方,cloudflare可以使用已批准的端口支持websockets。 Hence, I'm using 8443 for the Nginx port and another port for the node server. 因此,我使用8443作为Nginx端口,使用另一个端口作为节点服务器。 Using wscat it returns a 200 error. 使用wscat它会返回200错误。

$ wscat -c wss://xyz.com:8443
error: Error: unexpected server response (200)

I know that the websocket is expecting a 101 code. 我知道websocket期待101代码。 However, if I visit https://xyz.com:8443 , I can see the page displayed by the node server telling me proxy is working. 但是,如果我访问https://xyz.com:8443 ,我可以看到节点服务器显示的页面告诉我代理正在运行。 Also, once I turn off cloudflare support, the websocket starts working. 此外,一旦我关闭cloudflare支持,websocket就开始工作了。 Any clues to get this working. 有任何线索让这个工作。 I know I can create a subdomain but I'd prefer running the websocket behind cloudflare. 我知道我可以创建一个子域但我更喜欢在cloudflare后面运行websocket。

If you're trying to access this through CloudFlare's network you'd need to explicitly have web sockets enabled on your domain before they will work -- regardless of the port. 如果您尝试通过CloudFlare的网络访问此网站,则无论端口如何,您都需要在域名之前明确启用网络套接字。 As in, even if the port can pass through our network, that won't automatically mean that web sockets will be enabled or accessible on your domain. 同样,即使端口可以通过我们的网络,也不会自动意味着您的域上将启用或访问Web套接字。

You can try contacting our support team to request an exception to see if they can enable it for your domain, but typically this is still only available at the business and enterprise levels. 您可以尝试与我们的支持团队联系,以请求例外,以确定他们是否可以为您的域启用它,但通常只能在业务和企业级别使用。

Disclaimer: I work at CloudFlare. 免责声明:我在CloudFlare工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM