【问题标题】:Cloudflare Error 525 (if trying to connect via https ports) websocketCloudflare 错误 525(如果尝试通过 https 端口连接)websocket
【发布时间】:2021-01-14 12:48:49
【问题描述】:

我目前正在尝试测试基于 websocket 的 php 聊天。 https://github.com/sanwebe/Chat-Using-WebSocket-and-PHP-Socket

这是我目前正在尝试测试。 但我正在使用 cloudflare,通常使用 cloudflare 应该可以正常工作,但我总是得到

Error 525
SSL handshake failed

当我尝试这样访问它时: https://example.com:2096/chat/server.php

& 如果我尝试使用 chat ofc,结果相同。但这适用于使用 https 端口、8443 相同结果等的每个域。

我正在使用“完全(严格)”模式并且我安装了 cloudflare 安装的签名证书,所以我真的不知道问题出在哪里,使用 wss 并且当我禁用 SSL 时它可以工作,但我想要使其在 SSL ofc 上工作。

不使用 https 端口访问我的网站工作正常,所以它不能是“严格”模式,测试正常“完整”和灵活但结果相同。

提前感谢您的帮助。

编辑--

config (site infinite loading)

error log file

【问题讨论】:

  • 正在使用 apache2 或 nginx。你能告诉我们你的配置文件吗?
  • 我正在使用 apache2 (xampp)。我不知道如何在没有外部链接的情况下向您展示我的配置文件,但在这里:link 那是 httpd-ssl.conf 文件(其中的一部分)。

标签: php sockets websocket socket.io cloudflare


【解决方案1】:

通过在我的 httpd-ssl.conf 中添加它来修复它

SSLVerifyClient require
SSLVerifyDepth 1
SSLCACertificateFile "C:\xampp\apache\ssl\origin-pull-ca.pem"

SSLProxyEngine on
SSLProxyCACertificateFile "C:\xampp\apache\ssl\origin-pull-ca.pem"

RewriteEngine on
RewriteCond ${HTTP:Upgrade} websocket [NC]
RewriteCond ${HTTP:Connection} upgrade [NC]
RewriteRule .* "ws://localhost:8443/$1" [P,L]
  
#Redirecting websocket traffic
ProxyPass /server ws://localhost:8443/server
ProxyPassReverse /server ws://localhost:8443/server

感谢 Aviv Lo 浪费了一个多小时来帮助我!欣赏它。

【讨论】:

  • 别这么说@opalutscha。一起解决问题是一次非常愉快的经历。我也很感激 :)
【解决方案2】:

您可能缺少SSLProxyCACertificateFile 指令。

我使用带有 Nodejs 的 Socket.io 直接从我们的生产服务器获取此配置。我认为这可能会有所帮助。

<VirtualHost *:443>
        ServerName exmample.com
        ServerAlias www.exmample.com
        ServerAdmin admin@exmample.com
        DocumentRoot /var/www/exmample.com

        LogLevel debug  ssl:info
        SSLEngine on
        SSLCertificateFile /path/to/cert
        SSLCertificateKeyFile /path/to/key

        SSLVerifyClient require
        SSLVerifyDepth 1
        SSLCACertificateFile /etc/apache2/ca/origin-pull-ca.pem

        SSLProxyEngine on
        SSLProxyCACertificateFile /etc/apache2/ca/origin-pull-ca.pem


        RewriteEngine on
        RewriteCond ${HTTP:Upgrade} websocket [NC]
        RewriteCond ${HTTP:Connection} upgrade [NC]
        RewriteRule .* "wss:/localhost:2096/$1" [P,L]
  
        #Redirecting websocket traffic
        ProxyPass /shut / wss://localhost:2096/shut
        ProxyPassReverse /shut wss://localhost:2096/shut

        #Redirecting http traffic
        ProxyPass / http://localhost:2096/shut
        ProxyPassReverse / http://localhost:2096/shut
   


        ErrorLog ${APACHE_LOG_DIR}/exmaple_error_https.log
        CustomLog ${APACHE_LOG_DIR}/example_access_https.log combined

</VirtualHost>

【讨论】:

猜你喜欢
  • 2013-11-11
  • 1970-01-01
  • 2022-01-09
  • 2020-09-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-16
相关资源
最近更新 更多