问题描述
我正在尝试在我的 Ubuntu 14.04 和 apache2 版本 2.4.7 上安装 Mattermost 的 docker 版本。
这里是mattermost-ssl.conf
的配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName www.my.website.fr
ServerAlias website.fr
DocumentRoot /home/www/www-website
[...]
<Proxy *>
Require all granted
</Proxy>
ProxyPreserveHost On
ProxyRequests Off
RewriteEngine on
ProxyPass /mattermost http://localhost:8083
ProxyPassReverse /mattermost http://localhost:8083
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:8083%{REQUEST_URI} [P,QSA,L]
<Location /home/www/www-soft/mattermost>
Require all granted
ProxyPass http://127.0.0.1:8083/
ProxyPassReverse http://127.0.0.1:8083/
</Location>
[...]
</VirtualHost>
</IfModule>
该网站可以访问,但页面上没有显示任何内容,因为我收到了这样的错误消息(其他几个相同形式的示例中的一个):Failed to load resource: the server responded with a status of 404 (Not Found) https://www.my.website.fr/static/main.9e27a2872d73987ea8ec.css
而不是尝试在以下位置访问文件:
https://www.my.website.fr/mattermost/static/main.9e27a2872d73987ea8ec.css
(存在,我测试过)
(我用“my.website.fr”替换了我的网站域名)
apache 代理没有使用 /mattermost
前缀正确重定向是否有任何明显的原因?我错过了什么吗?
Mattermost 文档中的专用页面并没有帮助我解决这个问题 (https://docs.mattermost.com/install/config-apache2.html)
解决方法
来自 apache 文档:https://httpd.apache.org/docs/2.4/mod/core.html#location
该指令限制了所包含指令的范围 通过网址。
这意味着你需要改变:
<Location /home/www/www-soft/mattermost>
Require all granted
ProxyPass http://127.0.0.1:8083/
ProxyPassReverse http://127.0.0.1:8083/
</Location>
到
<Location /mattermost>
Require all granted
ProxyPass http://127.0.0.1:8083/
ProxyPassReverse http://127.0.0.1:8083/
</Location>
因为您的文档根目录设置为
DocumentRoot /home/www/www-website
您还使用 proxypass 来处理对同一路径的请求
ProxyPass /mattermost http://localhost:8083
ProxyPassReverse /mattermost http://localhost:8083
您需要选择要实施的解决方案:两者可能无法很好地协同工作。
最后,你也在使用
ProxyPreserveHost On
我不确定它是否需要/像您认为的那样工作:请参阅 https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost 以了解您的环境是否真的需要它。