Thanks for your help @coreyhulen but that gives me an error in my log files:
AH01144: No protocol handler was valid for the URL /api/v1/websocket. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule
and I get a blue bar error message a few seconds after loading up the instance:
"We cannot reach the Mattermost service. The service may be down or misconfigured. Please contact an administrator to make sure the WebSocket port is configured properly."
I have enabled tried to enable the proxy module like this:
$ sudo a2enmod proxy_http
Considering dependency proxy for proxy_http:
Module proxy already enabled
Module proxy_http already enabled
Here's my updated Apache VirtualHost file:
<VirtualHost *:443>
ServerName mattermost.example.com
ServerAlias mattermost.example.com
DocumentRoot /var/www/mattermost
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.pem
SSLCertificateKeyFile /etc/apache2/ssl/server.key
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/api/v1/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/v1/websocket>
Require all granted
ProxyPassReverse ws://127.0.0.1:8065/api/vi/websocket
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.example.com
</Location>
<Location />
Require all granted
ProxyPassReverse http://127.0.0.1:8065/
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.example.com
</Location>
</VirtualHost>