大家好。
我试图在 Docker 容器中设置 Discourse。主机环境(Debian)正在运行 Apache httpd 服务器(我无法运行 nginx,因为我正在 Apache 上托管其他网站)。我想使用 mod_proxy 反向代理到监听 3000 端口的容器。
该虚拟主机的当前 Apache 配置如下:
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName example.com
ServerAlias www.example.com
ErrorLog ${APACHE_LOG_DIR}/vhosts/example.com/error.log
CustomLog ${APACHE_LOG_DIR}/vhosts/example.com/access.log combined
<IfModule proxy_module>
## <https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247>
ProxyPreserveHost on
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</IfModule>
</VirtualHost>
我最初只使用了 ProxyPass 和 ProxyPassReverse 指令,然后逐个添加了 ProxyPreserveHost 和 RequestHeader 指令。无论我如何使用这些指令配置代理,文档根目录下的某些文件在访问时都会返回 404 错误(例如 /images 和 /assets 中的内容)。
请注意包含 Discourse Meta URL 的注释,我已将其从 nginx 语法转换为 Apache 语法。
任何关于如何解决此问题的建议都将不胜感激!