2017-06-04 30 views
0

我在本地在家裏使用的流量虛擬機中的mattermost。在我的DSL路由器上使用端口轉發功能時,我使用固定IP將我的WAN vHost上的子域映射到子域。Apache2 Websocket代理從動態dns主機的Mattermost

<VirtualHost *:80> 

    ServerName chat.domain.tld 
    ServerSignature Off 
    ProxyPreserveHost On 

    <Location /> 
    Order deny,allow 
    Allow from all 

    ProxyPassReverse http://chat.domain.tld/ 
    </Location> 

    RewriteEngine on 
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
    RewriteRule .* http://mappedsubdomain.somedyndns.tld:8090%{REQUEST_URI} [P,QSA] 

    DocumentRoot /somewhere/on/my/disk 

</VirtualHost> 

而且工作正常!在這種情況下,我將Web前端從端口8090映射到vHost子域的端口80。並且Web前端是可達的。

但是。

mattermost正在使用另一個端口通過Websockets與Web-Frontend進行通信。爲此我還從本地機器轉發了Websocket端口。如果我正在訪問動態DNS主機URL:http://mappedsubdomain.somedyndns.tld:8090,Web-Fontend可以很好地與第二個打開的Web端口端口配合使用。 Mattermost在動態DNS主機URL上可用。

由於默認Mattermost使用端口80作爲Websockets。但在我的情況下,我使用端口890爲Mattermost中的Websockets。它在本地,局域網內和動態DNS主機上工作。

現在,我想用Websocket協議做一個ProxyReverse。

廣域網主機是一個Debian與Apache2.2和加載mod_proxy_wstunnel模塊。

起初,我想簡單地映射第二端口:

Listen 890 
<VirtualHost *:890> 
    ServerName chat.domain.tld 
    ServerSignature off 

    ProxyRequests off 
    RewriteEngine on 

    RewriteCond %{HTTP:Upgrade} =websocket [NC] 
    RewriteRule /(.*)   ws://mappedsubdomain.somedyndns.tld:890/$1 [P,L] 

    RewriteCond %{HTTP:Upgrade} !=websocket [NC] 
    RewriteRule /(.*)   http://mappedsubdomain.somedyndns.tld:890/$1 [P,L] 

    <Location /> 
    Order deny,allow 
    Allow from all 

    ProxyPassReverse http://mappedsubdomain.somedyndns.tld:890/ 
    ProxyPassReverse ws://mappedsubdomain.somedyndns.tld:890/ 
    </Location> 

    DocumentRoot /somewhere/on/my/disk 

</VirtualHost> 

但一無所獲。 Websockets無法正常工作。

然後我試圖從一個WAN上的虛擬主機上運行的NodeJS的WebSocket隧道:

https://www.npmjs.com/package/wstunnel 

通過此調用:

wstunnel -t 8091 ws://mappedsubdomain.somedyndns.tld:890/ 

,並改變了虛擬主機配置:

RewriteRule /(.*)  ws://localhost:8091/$1 
RewriteRule /(.*)  http://localhost:8091/$1 [P,L] 
ProxyPassReverse  ws://localhost:8091/  
ProxyPassReverse  http://localhost:8091/ 

wstunnel正在運行時,chat.domain.tld:890上的http請求以tim EOUT。沒有wstunnel,我得到了503.

有沒有人對我有幫助?

+0

目前,我已經有了一個連接,但一個錯誤出現: 壞請求 {「ID」:「api.web_socket.connect .upgrade.app_error「,」message「:」Fehler beim Hochstufen der Websocket-Verbindung「,」detailed_error「:」「,」request_id「:」ytrcucx9jj8ymjedxtahndsaxy「,」status_code「:500} 表示:無法升級websocket連接 – seekwhencer

回答