[SOLVED] Apache reverse proxy with MM 4.0

Hi

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: Redirect)

thanks!

-R

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
  </Proxy>

  # 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://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
        # 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://127.0.0.1:8065/api/v%{env:MATCH_APIVERSION}/%{env:MATCH_APIUSERS}websocket
        ProxyPassReverse ws://127.0.0.1:8065/api/v%{env:MATCH_APIVERSION}/%{env:MATCH_APIUSERS}websocket
        ProxyPassReverseCookieDomain 127.0.0.1 mysubdomain.mydomain.com
  </LocationMatch>

  <Location />
        Require all granted
        ProxyPass http://127.0.0.1:8065/
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 mysubdomain.mydomain.com
  </Location>

</VirtualHost>

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!