Jeel
Jeel

Reputation: 2535

How to disable http to https re-direct in Jenkins?

I currently have Jenkins running behind SSL with http re-driecting to https. For a custom integration which doesn't support SSL yet, I need to disable the http to https re-direct. I am unable to do so by commenting the re-direct in apache conf.

Following is my apache config.

 <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>

How do i re-enable http without disabling https? Basically need to stop re-direction from http to https.

Upvotes: 0

Views: 2567

Answers (1)

JGK
JGK

Reputation: 4168

Based on you configuration, replace the <VirtualHost *:80> block with the following. But please note, passwords are now transfered in clear text.

<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>

This also includes that /sonar is also available over http.

Upvotes: 2

Related Questions