2016-07-29 148 views
0

我在我的服务器上使用棘轮websocket。它运行良好,没有SSL,但我需要使它与SSL一起工作。棘轮websocket SSL

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

关于增加在httpd.conf文件以下行,然后在这里我 想为 服务器是基于Debian和我们使用的Apache Web服务器,以告知我们没有使用的httpd服务器上。我相信 你可以在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是不正确的。

你有任何解决方案或提示?

UPDATE:

从我的理解,我们不能在.htaccess中使用的ProxyPass应该在服务器配置或虚拟主机配置的前提下使用。

我试图向支持人员解释,但他们似乎并不理解。

很明显,在.htaccess中禁止使用ProxyPass。

“ProxyPass和ProxyPassReverse仅在服务器 配置和虚拟主机上下文中可用。”

因此,如果您不能在服务器配置中添加此行,是否可以在虚拟主机上下文中添加 ?

他们的回答是:

当我再次回顾了服务器的水平,这 包括Apache模块和防火墙规则,使棘轮 的WebSockets能够在服务器上还运行所有的设置我们在防火墙中添加了 的规则表示在端口8000上允许来自外部的所有通信量为 ,我相信这应该足以让 允许websocket的外部连接。

截至目前,似乎你正在尝试使用 连接不同的端口(在https的情况下)。正如我们已经审查了服务器 的设置和配置,似乎都很好。

如果您可以让 这个过程中的开发人员参与其中,那么他可以更好地引导您,因为他知道代码级别 好得多。

眼下试图使用WSS连接会抛出:

WebSocket连接到 'WSS://127.198.132.141/wss2/' 失败: 的WebSocket打开握手被取消

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

+0

你解决了吗?我有同样的问题 – Andreah

+0

嗨,不幸的是,因为我不能在我的主机上配置太多。我现在不得不停止使用SSL。我仍然有兴趣找到解决方案;)。 – Brieuc

+0

我使用端口8888修复。我尝试过使用8080而没有成功。我也写了一个aswer,希望它有帮助。 – Andreah

回答

1

在你的虚拟主机添加:

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

不要忘了重新启动Apache服务

虚拟主机例如:

<IfModule mod_ssl.c> 
<VirtualHost *:443> 
     ServerAdmin [email protected] 
     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