[SOLVED] Apache reverse proxy with MM 4.0


In the changelog for MM 4.0, the following is mentioned for NGINX:

If you are using NGINX as a proxy for the Mattermost Server, replace the location /api/v3/users/websocket { line with location ~ /api/v[0-9]+/(users/)?websocket$ { in the /etc/nginx/sites-available/mattermost NGINX configuration file.

What is the appropriate change for apache (given this config: https://docs.mattermost.com/install/config-apache2.html)



I have not personally tested it but I suppose it would be something like this:

<VirtualHost *:80>
  # If you're not using a subdomain you may need to set a ServerAlias to:
  # ServerAlias www.mydomain.com
  ServerName mysubdomain.mydomain.com
  ServerAdmin hostmaster@mydomain.com
  ProxyPreserveHost On

  # setup the proxy
  <Proxy *>
         Order allow,deny
         Allow from all

  # Set web sockets
  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://{REQUEST_URI} [P,QSA,L]
        # This line simply forces HTTPS
  RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

  <LocationMatch "^/api/v(?<apiversion>[0-9]+)/(?<apiusers>users/)?websocket">
        Require all granted
        ProxyPass ws://{env:MATCH_APIVERSION}/%{env:MATCH_APIUSERS}websocket
        ProxyPassReverse ws://{env:MATCH_APIVERSION}/%{env:MATCH_APIUSERS}websocket
        ProxyPassReverseCookieDomain mysubdomain.mydomain.com

  <Location />
        Require all granted
        ProxyPassReverseCookieDomain mysubdomain.mydomain.com


Perhaps some one more proficient on the subject can enlighten you.

Sorry for the very delayed response…

Finally got the opportunity to try this out - it works perfectly, thanks!

Created a pull request to update the docs page: https://github.com/mattermost/docs/pull/1470

Thanks for trying it and confirming it works + the PR which is very welcome!