Apache反向代理 - 文件不存在

时间:2016-10-26 11:11:44

标签: apache proxy sonarqube reverse-proxy sonarqube-ops

我必须将Apache Web服务器配置为Sonarqube的反向代理。 Web服务器正在侦听端口 8888 ,并强制Sonarqube仅使用 127.0.0.1 (sonar.properties):

sonar.web.host=127.0.0.1

我有以下反向设置(httpd.conf):

ProxyRequests Off
ProxyPreserveHost On
<VirtualHost *:8888>
    ProxyPass /sonar http://127.0.0.1:9000/
    ProxyPassReverse /sonar http://127.0.0.1:9000/
</VirtualHost>

通过访问网址 http://10.130.210.80:8888/sonar ,会显示Sonarqube的初始页面,但没有任何CSS样式且没有图片。 Apache error.log告诉我以下内容:

[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/css, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/js, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/js, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/js, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/js, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/images, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/js, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/images, referer: http://10.130.210.80:8888/sonar
[Wed Oct 26 13:07:06 2016] [error] [client 10.130.211.88] File does not exist: /home/www/indian/htdocs/js, referer: http://10.130.210.80:8888/sonar

1 个答案:

答案 0 :(得分:1)

我得到了解决方案。首先,我为Sonarqube设置了一个上下文:

sonar.web.context=/sonarqube

其次,对于Apache,我设置了 Servername ,并将代理传递设置为Sonarqube的上下文:

ProxyRequests Off
ProxyPreserveHost On

<VirtualHost *:8888>
  ServerName 10.130.210.80:8888
  ProxyPass /sonarqube http://127.0.0.1:9000/sonarqube
  ProxyPassReverse /sonarqube http://127.0.0.1:9000/sonarqube
</VirtualHost>

和&#34; Tadaaa&#34;,有效!