首页 > 解决方案 > Apache2(httpd)反向代理无法与 Docker Compose 上的 SonarQube 服务器一起使用

问题描述

我在 apache 中的反向代理(CentOS 8 中的 httpd)不工作。我有一个带有 CentoOS 的虚拟机,在它上面我有一个在 http://localhost:8000 上运行的 django 应用程序,并且反向代理可以工作。

我复制应用程序的 .conf 文件以放置另一个 django 应用程序和 sonarqube。我创建了具有相同内容的 .conf 文件,只调整了应用程序名称及其目录。它只是不起作用!!!!:'(

我使用 docker-compose 放置了一个 sonarqube 服务器来运行。声纳服务器在 http://localhost:9000 运行。但是,当通过 URL http://myhost.com/sonar访问时,该站点无法打开,错误 404 Not Found。

  1. 它与docker-compose有关吗?
  2. 我的虚拟主机配置是否正确?
  3. 我在 VirtualHosts 中是否有任何配置冲突?
  4. 跟根目录有关系吗?

我在 sonar.conf 中的虚拟主机:

<VirtualHost *:80>
  ServerName www.myhost.com
  ServerAlias ​​myhost.com
  ServerAdmin admin@myhost.com

  <Directory /var/www/html>
       Require all granted
  </Directory>

  ProxyPass "/sonar" "http://localhost:9000"
  ProxyPassReverse "/sonar" "http://localhost:9000"

  <Location "/sonar">
      order allow,deny
      Allow from all
  </Location>

</VirtualHost>

如果我输入日志信息,浏览器会显示日志目录:

ErrorLog /var/www/html/sonar/log/error.log
CustomLog /var/www/html/sonar/log/requests.log combined

Apache 显示声纳/日志目录

标签: dockerapachesonarqubereverse-proxy

解决方案


推荐阅读