当前位置: 首页 > 知识库问答 >
问题:

棘轮websocket SSL

长孙哲
2023-03-14

我读过这篇stackoverflow帖子。不幸的是,我的PAAS支持不使用httpd.conf。他们建议我直接在。htaccess中添加ProxyPass。

关于在httpd.conf文件中添加以下一行,在这里我要告知,我们在服务器上没有使用httpd,因为服务器是基于Debian的,我们使用的是Apache web服务器。我相信您可以在htaccess文件中使用相同的代码行,或者如果您可以咨询开发人员,这将是更好的。

# ProxyPass for Ratchet with SSL
ProxyPass /wss2/ ws://127.198.132.141:8000/

# Preventing the app from being indexed
Header set X-Robots-Tag "noindex, nofollow"

# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php

# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks

# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
# to the front controller "/app.php" but be rewritten to "/app.php/app".
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On
    [...]

不幸的是,添加ProxyPass/wss2/ws://127.198.132.141:8000/会使服务器崩溃,就像.htaccess不正确一样。

我再次查看了服务器级别上的所有设置,其中包括Apache模块和防火墙规则,以使棘轮websockets能够在服务器上运行,我们在防火墙中添加的规则表明所有来自外部的通信都允许在端口8000上进行,我相信这应该足以允许WebSocket的外部连接。

到目前为止,您似乎正在尝试使用不同的端口建立连接(在https的情况下)。因为我们已经审查了服务器的设置和配置,一切似乎都很好。

如果您能让开发人员参与到这个过程中,这样他就能更好地指导您,因为他对代码级别的事情了解得更好,这将是非常感激的。

而将http与ws一起使用则运行良好。

共有1个答案

连正信
2023-03-14

在虚拟主机中添加:

proxypass/wss2/ws://yourdomain.xxx:8888/(尝试使用端口8888)

不要忘记重新启动apache服务

虚拟主机示例:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

SSLCertificateFile /etc/letsencrypt/live/yourdomain.xxx/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.xxx/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ServerName yourdomain.xxx
ProxyPass /wss2/ ws://yourdomain.xxx:8888/
</VirtualHost>
</IfModule>

您可以在这里找到完整的工作示例https://github.com/ratchetphp/ratchet/issues/100

 类似资料:
  • 问题内容: 我有一个棘手的聊天服务器文件 我使用Websocket进行连接,效果很好 我想要安全连接,因此我尝试使用SSL连接,但无法正常工作。 我的问题是 如何将Websocket与SSL连接连接 任何的想法? 问题答案: 如果您使用的是Apache Web服务器(2.4或更高版本),请在httpd.conf文件中启用以下模块: mod_proxy.so mod_proxy_wstunnel.s

  • 我试图通过使用棘轮来测试简单的WebSockets乒乓响应。我的WebSocket服务器看不到来自web浏览器的WebSocket客户端的任何响应,但浏览器可以很好地看到WebSocket服务器发送的数据包。我在找原因。 我目前的猜测是: 缺少一些HTTP标头 我必须在浏览器上对数据包进行编码 CloudFlare无法将WS流中的数据包识别为有效数据包,并将其处理 EC2实例中的CloudFlar

  • Netty中是否有任何嵌入式优先级机制可以帮助我决定哪些消息比其他消息发送得更频繁?

  • 下面的代码仅在观察2完成后才从观察1发出项。 我需要实现另一种行为 第二个可观测对象仅发射项目,而第一个可观测对象为空,然后发射第一个可观测对象的项目。 我无法找到只使用基本运算符的正确解决方案,自定义运算符startWithDefault的正确RxJava 2实现应该是什么样子? 附笔。 由于种族原因,在可观察到立即发射的情况下,这不是正确的解决方案1

  • 问题内容: 有一段时间遇到这个麻烦。 我有这样的数据库: 我要执行搜索,找到最便宜的汽车,然后按价格升序订购其余相同品牌的汽车。 我希望我的输出是这样的: 最便宜的汽车是福特嘉年华(Forest Fiesta),因此,其余福特车型都按照价格直接订购。然后,本田拥有第二便宜的车型,因此爵士车和其他本田车紧随其后,依此类推。 这可能吗? 问题答案: 您需要做的是创建一个瞬态数据集,该数据集包含car_