Reputation: 5251
I really need your help! I've posted this question a month ago in a lot of linux and web forums and also directly at Mattermost but without any success and I really really need this tool. So I hope you came across this problem by yourself and maybe you can help me.
Since I'm already using GitLab and GitLab comes with a build-in Mattermost installation, I used that one. After installing it, I can reach Mattermost via 127.0.0.1:8065
. So far so good but since I want to use it via an URL, I've created a subdomain in Plesk and added some additional Apache directives like described here:
HTTP:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/.well-known/.*
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [last,redirect=301]
HTTPS:
ServerName mattermost.xxx.de
ProxyPreserveHost On
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}
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 .* ws://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
<Location />
Require all granted
ProxyPass http://127.0.0.1:8065/
ProxyPassReverse http://127.0.0.1:8065/
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.xxx.de
</Location>
ErrorLog /var/log/apache2/mattermost_error.log
CustomLog /var/log/apache2/mattermos_forwarded.log common_forwarded
CustomLog /var/log/apache2/mattermos_access.log combined env=!dontlog
CustomLog /var/log/apache2/mattermos.log combined
Also I've enabled SSL for that domain directly inside Plesk with Lets Encrypt. To be sure everything works, I've also allowed unsecure connections from Mattermost because of a self-signed certificate.
I'm now able to reach Mattermost via https
and also the certificate looks great. But now I've a big problem: The websocket don't works and I'm getting this error inside my console:
Without a websocket, a chatting tool makes no sense. Also I've found this error inside the custom error log defined in the additional directives above:
AH01144: No protocol handler was valid for the URL /api/v4/websocket (scheme 'ws'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
I've researched a lot about this issue and enabled a lot of Apache modules in Plesk but without any success:
I really need this for an important dev project. I hope you know an answer - I am at the end of my rope...
Upvotes: 0
Views: 2913
Reputation: 1894
ditch the rewrite rules and use proxypassmatch
proxyPassMatch ^(/api/v[0-9]+/(users/)?websocket.*)$ ws://127.0.0.1:8065/$1
<VirtualHost *:443>
ServerName mattermost.xxx.de
##ssl stuff
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}
proxyPassMatch ^(/api/v[0-9]+/(users/)?websocket.*)$ ws://127.0.0.1:8065/$1
ProxyPass / http://127.0.0.1:8065/
ProxyPassReverse / http://127.0.0.1:8065/
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.xxx.de
ProxyPreserveHost On
ErrorLog /var/log/apache2/mattermost_error.log
CustomLog /var/log/apache2/mattermos_forwarded.log common_forwarded
CustomLog /var/log/apache2/mattermos_access.log combined env=!dontlog
CustomLog /var/log/apache2/mattermos.log combined
</VirtualHost>
Upvotes: 1