Mattermost, Inc.

[Solved] 500 Code in Apache log because of Websocket

Hello everyone

I just upgraded Mattermost to the version 3.0.2. It works all fine only that I see in the apache log this:

[23/May/2016:17:56:18 +0200] “GET /api/v3/users/websocket HTTP/1.1” 500

Here is the relevant configuration of my apache:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/api/v3/users/websocket [NC,OR]
RewriteCond %{HTTP:UPGRADE} ^Websocket$ [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://xxxx:8065%{REQUEST_URI} [P,QSA,L]

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://xxxx:8065%{REQUEST_URI} [P,QSA,L]
RequestHeader set X-Forwarded-Proto “https”

<Location /api/v3/users/websocket>
Require all granted
ProxyPassReverse ws://xxxx:8065/api/v3/users/websocket
ProxyPassReverseCookieDomain xxxx:8065 xxxx

Require all granted ProxyPassReverse http:/xxxx:8065/ ProxyPassReverseCookieDomain xxxx xxxx

I don’t understand because Apache gives a 500 because i think Mattermost works fine like before. The only thing that I noticed is that the browser takes longer until it gets the status of the other users.

Thanks for your help

1 Like

Hello,

I was wondering if you resolved this. If so, could you post your answer for us? I have reported a problem that led me to a configuration that no longer works. If you got yours working, that would be great.

Thank you

I resolved my issue using advice from this thread. In essence, It required the addition of the mod_proxy_wstunnel. In Jessie, I did it with:

sudo a2enmod proxy_wstunnel

For posterity, here’s the working config:

<VirtualHost x.x.x.x:443>
ServerName my.mattermost.org
SSLCertificateFile /etc/letsencrypt/live/my.mattermost.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my.mattermost.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

ProxyPreserveHost On
ProxyRequests Off

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/api/v3/users/websocket [NC,OR]
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule .* http://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
RequestHeader set X-Forwarded-Proto "https"

  <Location /api/v3/users/websocket>
    Require all granted
    ProxyPassReverse ws://127.0.0.1:8065/api/v3/users/websocket
    ProxyPassReverseCookieDomain 127.0.0.1 my.mattermost.org
  </Location>

  <Location />
    Require all granted
    ProxyPassReverse https://127.0.0.1:8065/
    ProxyPassReverseCookieDomain 127.0.0.1 my.mattermost.org
  </Location>
</VirtualHost>