ssl - 是否有计划将 HTTPS 添加回 SonarQube?

标签 ssl sonarqube sonarqube-ops

我正在使用反向代理运行 SonarQube。但是,出于安全原因,我还在 SonarQube 和数据库之间使用 X.509 身份验证。从 5.4 升级到 5.6 后,我无法再连接到我的 PostgreSQL 数据库,因为证书没有通过。

  • 在协商与数据库的 SSL 连接时,是否有另一种方法可以将 SonarQube 配置为使用本地 keystore ?
  • 是否有计划重新添加 SSL 支持?
  • 是否有计划重新添加 WAR 风格的部署?

  • 我可能会卡在5.4。

    最佳答案

    SonarQube 使用反向代理支持 HTTPS。这是官方文档和链接:

    To run the SonarQube server over HTTPS, you must build a standard reverse proxy infrastructure. The reverse proxy must be configured to set the value "X_FORWARDED_PROTO: https" in each HTTP request header. Without this property, redirection initiated by the SonarQube server will fall back on HTTP.



    使用 Apache 代理

    我们假设您已经安装了带有模块 mod_proxy 的 Apache 2,SonarQube 正在运行并可在 http://private_sonar_host:sonar_port/ 上使用。并且您想为 www.public_sonar.com 配置一个虚拟主机。
    此时,编辑 www.public_sonar.com 虚拟主机的 HTTPd 配置文件。包括以下内容以通过 http://www.public_sonar.com/ 的 mod_proxy 公开 SonarQube :
        ProxyRequests Off
    ProxyPreserveHost On
    <VirtualHost *:80>
      ServerName www.public_sonar.com
      ServerAdmin admin@somecompany.com
      ProxyPass / http://private_sonar_host:sonar_port/
      ProxyPassReverse / http://www.public_sonar.com/
      ErrorLog logs/somecompany/sonar/error.log
      CustomLog logs/somecompany/sonar/access.log common
    </VirtualHost>
    

    使用 Nginx

    我们假设您已经安装了 Nginx,您正在使用 www.somecompany.com 的虚拟主机,并且 SonarQube 正在运行并可在 http://sonarhost:sonarport/ 上使用。 .
    此时,编辑 Nginx 配置文件。包括以下内容以在 http://www.somecompany.com/ 上公开 SonarQube :
    # the server directive is nginx's virtual host directive
    server {
      # port to listen on. Can also be set to an IP:PORT
      listen 80;
    
      # sets the domain[s] that this vhost server requests for
      server_name www.somecompany.com;
    
      location / {
        proxy_pass http://sonarhost:sonarport;
      }
    }
    

    使用 IIS

    SonarQube 建议使用反向代理来保护您的 Sonar 安装。在 IIS 和 Url Rewrite 模块的帮助下,设置起来轻而易举。

    你需要什么:
  • 在机器上启用 IIS(不必是 SonarQube 机器,但我假设您在同一系统上执行此操作)
  • IIS 的 URL 重写扩展 (https://www.iis.net/downloads/microsoft/url-rewrite)
  • IIS 的基于应用程序的路由扩展 (https://www.iis.net/downloads/microsoft/application-request-routing)
  • SSL 证书(可以是自签名的或真实的)

  • 第一步是创建一个 IIS 网站作为反向代理。

    enter image description here

    除非您需要进行 Kerberos 身份验证,否则您不需要在反向代理上配置任何形式的身份验证。如果您在那里配置了 Active Directory 集成,它应该转发来自 SonarQube 的挑战。

    enter image description here

    如果您使用的是 Kerberos 或 IIS 高级保护,请在此处查看有关正确配置的指南。 (https://blogs.technet.microsoft.com/latam/2015/06/24/kerberos-authentication-and-application-request-routing/)

    将绑定(bind)配置为使用 SSL 并设置正确的主机名和证书。我通过使用安装在我的机器上的 IIS Express 开发证书来作弊:

    enter image description here

    接下来我们将打开 URL Rewrite 设置来配置反向代理:

    enter image description here

    单击添加规则以创建新规则:

    enter image description here

    并从模板列表中选择“反向代理”:

    enter image description here

    输入目标服务器 URL(可以是 http://localhost:9000 ,甚至是远程服务器),然后单击确定创建规则:

    enter image description here

    您回到 URL 重写屏幕,我们需要添加一个额外的服务器变量,我们将连同请求一起发送到其他服务器,以便告诉 SonarQube 它实际上位于执行 SSL 卸载的反向代理后面它:

    enter image description here

    单击“添加...”以创建服务器变量:

    enter image description here

    添加服务器变量“X_FORWARDED_PROTO”以允许重写模块操作此 header :

    enter image description here

    您现在应该在变量列表中列出了变量。单击“返回规则”以返回规则列表:

    enter image description here

    编辑您刚刚创建的 URL 重写规则:

    enter image description here

    展开规则定义的服务器变量部分:

    enter image description here

    添加您在上一步中允许的“X_FORWARDED_PROTO” header ,并为其指定值“https”:

    enter image description here

    应用更改:

    enter image description here

    现在您应该能够通过 SSL 访问 SonarQube。您可能希望将原始 SonarQube 实例配置为仅接受来自反向代理的流量或仅接受来自 localhost 通过 Windows 防火墙的流量。

    复制自:

    USING IIS

    Server setup documentation

    关于ssl - 是否有计划将 HTTPS 添加回 SonarQube?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38593463/

    相关文章:

    python - 通过 FTP_TLS 上传文件到 FTP 服务器得到错误 ssl

    configuration - Sonar - 如何使用 sonnar-runner 创建子项目

    java - Sonar 项目与 Sonar 模块( Sonar 项目的一部分)

    sonarqube - NFS(Kubernetes)上的SonarQube插件目录

    security - 在 javascript 中创建的 cookie 的安全属性

    ruby-on-rails-3 - 与 Rails 中的 Force_SSL 相反?

    SSL证书编译成pem文件

    java - 报告超出 Sonar 服务器的最大上传大小

    active-directory - sonarqube - 事件目录 ldap 错误代码 49

    apache - 在 RedHat 的反向代理后面设置 Sonarqube