【问题标题】:How to redirect only websocket request to another server from apache windows?如何仅将 websocket 请求从 apache windows 重定向到另一台服务器?
【发布时间】:2019-12-05 07:37:45
【问题描述】:

我有一个 Apache2.4 配置,它适用于 HTTPS 请求。

现在,我正在尝试将 wss(WebSocket) 请求重定向到另一台服务器,它正在运行(在同一台服务器上,但在端口 8000 上)。

<VirtualHost *:8080>

    ServerAdmin YYYY.YYYY@XXXXX.com

    SSLEngine on
    SSLCertificateFile "D:/cert/certificate.cert"
    SSLCertificateKeyFile "D:/cert/privatekey.key"

    # This is how I tried to redirect.
    RewriteEngine On
    RewriteCond %{HTTP:Connection} Upgrade [NC]
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteRule /(.*) wss://127.0.0.1:8000/$1  [P,L]

我的 WebSocket 网址:

wss://127.0.0.1:8000/ws/home

上述配置不起作用。请帮忙!

我点击浏览器https://127.0.0.1:8080/ 页面加载了很长时间而屏幕上没有任何响应。

Edit-1:

我通过使用&lt;Location 'path'&gt; 解决了。谁能帮我处理所有的 WebSocket URL?

【问题讨论】:

    标签: windows apache proxy reverse-proxy


    【解决方案1】:

    我已经使用下面的代码解决了这个问题。

    <VirtualHost *:8080>
    
        ServerAdmin YYYY.YYYY@XXXXX.com
    
        SSLEngine on
        SSLCertificateFile "D:/cert/certificate.cert"
        SSLCertificateKeyFile "D:/cert/privatekey.key"
    
        <Location "/ws/home">
           ProxyPass "wss://127.0.0.1:8000/ws/home"
        </Location>
    

    但这不适用于所有 WebSocket URL。

    【讨论】:

      猜你喜欢
      • 2012-11-22
      • 2018-12-15
      • 2012-04-23
      • 2011-06-07
      • 1970-01-01
      • 2014-02-12
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多