如何在Jenkins中禁用HTTP到https重定向?

时间:2018-11-22 06:54:33

标签: apache jenkins reverse-proxy

我目前有Jenkins在SSL后面运行,并且将HTTP重新重定向到https。对于尚不支持SSL的自定义集成,我需要禁用http到https的重定向。我无法通过在apache conf中评论重定向来做到这一点。

以下是我的Apache配置。

 <VirtualHost *:80>
  ServerName jenkins-tb.myorg.com
  ServerAlias www.jenkins-tb.myorg.com
  ProxyRequests Off
  ProxyVia On
  Redirect permanent / https://jenkins-tb.myorg.com/
#  RewriteEngine On
#  RewriteCond %{HTTPS} !=on
#  RewriteRule ^/?login/(.*) https://%{SERVER_NAME}/login/$1 [R,L]
</Virtualhost>


<VirtualHost *:443>
  ServerName jenkins-tb.myorg.com
  ServerAlias www.jenkins-tb.myorg.com

  SSLEngine On
  SSLProxyEngine On
  SSLCertificateFile    /etc/apache2/ssl/crt/jenkins-asd.myorg.com.crt
  SSLCertificateKeyFile /etc/apache2/ssl/key/server_jenkins-asd.myorg.com.key

  ProxyRequests     Off
  ProxyPass         /  http://localhost:8080/
  ProxyPassReverse  /  http://localhost:8080/
 # ProxyPassReverse /login http://jenkins-thunderbolt.myorg.com/login
 # ProxyPassReverse /login https://jenkins-thunderbolt.myorg.com/login

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

  RequestHeader set X_FORWARDED_PROTO "https"
  RequestHeader set X-Forwarded-Port "443"
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1

  <Proxy http://localhost:8080/*>
   Order allow,deny
    Allow from all
  </Proxy>
  ProxyPreserveHost on
#  AllowEncodedSlashes NoDecode
</VirtualHost>

如何在不禁用https的情况下重新启用http?基本上需要停止从http到https的重定向。

1 个答案:

答案 0 :(得分:1)

根据您的配置,将<VirtualHost *:80>块替换为以下内容。但请注意,密码现在已以明文形式传输

<VirtualHost *:80>
  ServerName jenkins-tb.myorg.com
  ServerAlias www.jenkins-tb.myorg.com

  ProxyRequests     Off
  ProxyPass         /  http://localhost:8080/
  ProxyPassReverse  /  http://localhost:8080/

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

  RequestHeader set X_FORWARDED_PROTO "http"
  RequestHeader set X-Forwarded-Port "80"
  SetEnv force-proxy-request-1.0 1
  SetEnv proxy-nokeepalive 1

  <Proxy http://localhost:8080/*>
   Order allow,deny
    Allow from all
  </Proxy>
  ProxyPreserveHost on
</Virtualhost>

这还包括/sonar也可以在http上使用。