我在测试环境中成功部署了 Apache2,将其作为反向代理连接到容器内的 Unix 套接字,过程“毫无问题”:
我找到的唯一区别(注意:仅测试了几个小时,尚不完整)是:
- Apache2 无法与容器共享卷中指向 Unix 套接字的符号链接配合使用;
- 在粗略测试中,Apache2 的速度稍慢,但差异不大。
就个人而言,我不喜欢针对技术的无谓争论;因此,我不同意“Apache2 会带来很多问题”的说法。在我的测试过程中,Apache2 并未出现任何负面问题。
以下是我使用 Apache2 的核心配置(HTTP 工作正常,顺便提一下,LETSENCRYPT 也完全兼容):
# cat discourse.example.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName discourse.example.com
DocumentRoot /website/discourse
RewriteEngine On
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/
ProxyPassReverse / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/
ErrorLog /var/log/apache2/discourse.error.log
LogLevel warn
CustomLog /var/log/apache2/discourse.access.log combined
RewriteCond %{SERVER_NAME} =discourse.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
注意:我们唯一遇到问题的情况是,即使设置了 force_https,HTTP 仍然被提供,那是因为 /uploads 目录中缺少文件,但这(当然)与使用 Apache2 还是 nginx 作为反向代理无关。