Sorry, I'm not too familiar with apache, but I based on the error message we cannot establish a websocket connection to the mattermost server. Usually this means the connection cannot be upgraded from http:// to ws:// or https:// to wss://. The websocket connects on the same port. It starts off as the http protocol then gets upgraded to ws protocol.
I'm guessing somethings wrong with the following lines
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]