Last active
May 3, 2018 12:32
-
-
Save misje/52551fc43754d2e27f32 to your computer and use it in GitHub Desktop.
Mattermost Apache config example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName mattermost.example.org | |
ServerAdmin webmaster@example.org | |
ErrorLog ${APACHE_LOG_DIR}/mattermost-error.log | |
CustomLog ${APACHE_LOG_DIR}/mattermost-access.log combined | |
# Enforce HTTPS: | |
RewriteEngine On | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] | |
</VirtualHost> | |
<VirtualHost *:443> | |
SSLEngine on | |
ServerName mattermost.example.org | |
ServerAdmin webmaster@example.org | |
ErrorLog ${APACHE_LOG_DIR}/mattermost-error.log | |
CustomLog ${APACHE_LOG_DIR}mattermost-access.log combined | |
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] | |
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f | |
RewriteRule .* http://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L] | |
RequestHeader set X-Forwarded-Proto "https" | |
RequestHeader unset If-Modified-Since | |
RequestHeader unset If-None-Match | |
<LocationMatch "/api/(?<version>v[0-9]+)/(?<users>users/)?websocket$"> | |
Require all granted | |
ProxyPassReverse ws://127.0.0.1:8065/api/v%{env:MATCH_VERSION}/%{env:MATCH_USERS}websocket | |
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.example.org | |
</LocationMatch> | |
<Location /> | |
Require all granted | |
ProxyPassReverse http://127.0.0.1:8065/ | |
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.example.org | |
</Location> | |
ProxyPreserveHost On | |
ProxyRequests Off | |
</VirtualHost> |
is there any specific reason for the Api Version in line "RewriteCond %{REQUEST_URI} ^/api/v1/websocket [NC,OR]" ?
Why not v3, or v4 or a RegEx?
Should i change this manually from version to version of mattermost?
is there any specific reason for the Api Version in line "RewriteCond %{REQUEST_URI} ^/api/v1/websocket [NC,OR]" ?
Why not v3, or v4 or a RegEx?
Should i change this manually from version to version of mattermost?
It always worked for me. I updated the regex with a numeric match to any version anyway. The ProxyPassReverse path also lacked a "v" before the version number, but this never seemed to be a problem.
This config now closely resembles the unofficial apache config in the Mattermost docs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry it's perfect
I had a header directive which broke everything