apache - 反向代理 apache2 后面的 Mattermost docker 重定向错误
问题描述
我正在尝试使用 apache2 版本 2.4.7 在我的 Ubuntu 14.04 上安装 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”替换了我的网站域)
/mattermost
apache代理没有使用前缀正确重定向有什么明显的原因吗?我错过了什么吗?
Mattermost 文档中的专用页面并没有帮助我解决这个问题(https://docs.mattermost.com/install/config-apache2.html)
解决方案
来自 apache 文档:https ://httpd.apache.org/docs/2.4/mod/core.html#location
该指令通过 URL 限制所附指令的范围。
这意味着您需要更改:
<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以了解您的环境是否真的需要它。
推荐阅读
- rust - 如何将值从一个枚举变体移动到另一个?
- c# - 模板 Xamarin.Forms Shell 应用程序中的 InvalidCastException
- api - Snapchat API 错误:出现错误 无效的 redirect_uri
- rust - `assert_eq!(a, b)` 和 `assert_eq!(a, b, )` 之间有区别吗?
- r - grepl ifelse 没有显示正确的值(R)
- javascript - 元素 ref 被指定为字符串 (wrappedInstance) 但未设置所有者。在 Netlify CMS 自定义小部件中连接到 Redux 存储
- firebase - Flutter - Firebase Auth + Firestore - 不同的查询结果
- typescript - 获取泛型容器名称
- java - 清单中 Jar 的 JDK 版本与构建版本不匹配
- sql-server - 如果符号存在,则从 SQL Server 中的字符串在符号之后到字段末尾的子字符串