【发布时间】:2021-05-26 21:12:35
【问题描述】:
我真的需要你的帮助!一个月前,我在很多 linux 和网络论坛上发布了这个问题,也直接在 Mattermost 上发布了这个问题,但没有任何成功,我真的很需要这个工具。所以我希望你自己遇到这个问题,也许你可以帮助我。
因为我已经在使用 GitLab 并且 GitLab 带有内置的 Mattermost 安装,所以我使用了那个。安装后,我可以通过127.0.0.1:8065 访问 Mattermost。到目前为止一切顺利,但由于我想通过 URL 使用它,所以我在 Plesk 中创建了一个子域,并添加了一些 additional Apache directives,就像描述的 here:
HTTP:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/.well-known/.*
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [last,redirect=301]
HTTPS:
ServerName mattermost.xxx.de
ProxyPreserveHost On
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}
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]
<Location />
Require all granted
ProxyPass http://127.0.0.1:8065/
ProxyPassReverse http://127.0.0.1:8065/
ProxyPassReverseCookieDomain 127.0.0.1 mattermost.xxx.de
</Location>
ErrorLog /var/log/apache2/mattermost_error.log
CustomLog /var/log/apache2/mattermos_forwarded.log common_forwarded
CustomLog /var/log/apache2/mattermos_access.log combined env=!dontlog
CustomLog /var/log/apache2/mattermos.log combined
我还使用 Lets Encrypt 直接在 Plesk 内为该域启用了 SSL。为了确保一切正常,由于自签名证书,我还允许来自 Mattermost 的不安全连接。
我现在可以通过 https 访问 Mattermost,而且证书看起来很棒。但现在我遇到了一个大问题:websocket 不起作用,我在控制台中收到此错误:
没有 websocket,聊天工具就没有意义。我还在上面附加指令中定义的自定义错误日志中发现了这个错误:
AH01144: No protocol handler was valid for the URL /api/v4/websocket (scheme 'ws'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
我对这个问题进行了很多研究,并在 Plesk 中启用了很多 Apache 模块,但没有任何成功:
对于一个重要的开发项目,我真的需要这个。我希望你知道答案——我已经走到了尽头......
【问题讨论】:
-
这是一些相对复杂的东西。我不确定所有这些重写规则在做什么。但我的直觉告诉我不需要它们。我会删除它们,只是让它们代理规则。如果这不能解决问题,我很想尝试使用 nginx 作为反向代理,看看你是否会得到不同的行为。
标签: linux apache ubuntu websocket plesk