# \[solved\] Apache reverse proxy to foreign server wss issue

**URL:** <https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143>\
**Category:** Troubleshooting\
**Created:** [April 24, 2019, 5:55am UTC](https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143 "2019-04-24T05:55:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![qmor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/qmor/32/2860_2.png) [@qmor](https://forum.mattermost.com/u/qmor)\
**Post date:** [April 24, 2019, 5:55am UTC](https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143/1 "2019-04-24T05:55:36Z")

</div>

#### Summary

Wss proxy passing doesnot working

#### Steps to reproduce

I’ve got a gitlab 11 server in my local network at address 192.168.3.230 and reverse proxy server on address 192.168.3.35 which passing traffic from internet to intranet. I’ve successfully setted up gitlab proxy pass and mattermost proxypass in partial (login page and mattermost site works as well, but not a websockets. my apache conf listed below:

\<VirtualHost _:443\>  
SSLEngine on  
SSLProxyEngine On  
ServerName [mattermost.server.org](http://mattermost.server.org)  
ErrorLog /var/log/apache2/mattermost-error.log  
CustomLog /var/log/apache2/mattermost-access.log combined  
RewriteEngine On  
RewriteCond %{REQUEST\_URI} ^/api/v[0-9]+/(users/)?websocket [NC,OR]  
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]  
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]  
RewriteRule ._ wss://192.168.3.230:8065%{REQUEST\_URI} [P,QSA,L]  
#RewriteCond %{DOCUMENT\_ROOT}/%{REQUEST\_FILENAME} !-f  
#RewriteRule .\* [https://192.168.3.230:8065](https://192.168.3.230:8065)%{REQUEST\_URI} [P,QSA,L]  
RequestHeader set X-Forwarded-Proto “https”

```
    RequestHeader unset If-Modified-Since
    RequestHeader unset If-None-Match

    <LocationMatch "/api/(?<version>v[0-9]+)/(?<users>users/)?websocket$">
            Require all granted
            ProxyPassReverse wss://192.168.3.230:8065/api/v%{env:MATCH_VERSION}/%{env:MATCH_USERS}websocket
            ProxyPassReverseCookieDomain 192.168.3.230 mattermost.server.org
    </LocationMatch>
    <Location />
            Require all granted
            ProxyPass https://192.168.3.230/
            ProxyPassReverse https://192.168.3.230/
            ProxyPassReverseCookieDomain 192.168.3.230 mattermost.server.org
    </Location>

    ProxyPreserveHost On
    ProxyRequests Off
    SSLCertificateFile /etc/letsencrypt/live/mattermost.server.org/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/mattermost.server.org/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

```

#### Observed behavior

websocket\_client.jsx:38 WebSocket connection to wss://mattermost.server.org/api/v4/websocket’ failed: Error during WebSocket handshake: Unexpected response code: 503

is it possible to proxy wss websocket?

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [April 24, 2019, 10:11pm UTC](https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143/2 "2019-04-24T22:11:12Z")

</div>

Hi @qmor,

It should be possible to proxy websockets (even with [Apache](https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html) - as described in the [documentation](https://docs.mattermost.com/install/config-apache2.html)). One of our community members suggests you to investigate which service returned the `503` . Mattermost or your Apache proxy? Log files might provide additional insights.

---

<div class="post-metadata">

**Author:** ![qmor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/qmor/32/2860_2.png) [@qmor](https://forum.mattermost.com/u/qmor)\
**Post date:** [April 25, 2019, 12:26pm UTC](https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143/3 "2019-04-25T12:26:22Z")

</div>

got some apacke2 logs

[Wed Apr 24 16:01:03.723277 2019] [proxy:error] [pid 18975:tid 140161291581184] (111)Connection refused: AH00957: WSS: attempt to connect to 192.168.3.230:8065 (\*) failed  
[Wed Apr 24 16:01:03.723352 2019] [proxy\_wstunnel:error] [pid 18975:tid 140161291581184] [client 192.168.3.17:28317] AH02452: failed to make connection to backend: 192.168.3.230

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [April 30, 2019, 12:14pm UTC](https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143/4 "2019-04-30T12:14:20Z")

</div>

Hi @qmor, Do you have any information in your Mattermost logs - around Wed Apr 24 16:01:03 2019 - why Mattermost refused that connection?

---

<div class="post-metadata">

**Author:** ![qmor](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/qmor/32/2860_2.png) [@qmor](https://forum.mattermost.com/u/qmor)\
**Post date:** [April 30, 2019, 6:08pm UTC](https://forum.mattermost.com/t/solved-apache-reverse-proxy-to-foreign-server-wss-issue/7143/5 "2019-04-30T18:08:58Z")

</div>

looks like i’ve solved a problem. just need to redirect mattermost wss connection to 443 port not 8065

RewriteRule .\* wss://192.168.3.230:443%{REQUEST\_URI} [P,QSA,L]

instead of

RewriteRule .\* wss://192.168.3.230:8065%{REQUEST\_URI} [P,QSA,L]
