Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


No Format
# If you already have an haproxy.cfg file, you can probably leave the
# global and defaults section as-is, but you might need to increase the 
# timeouts so that long-running CLI commands will work.
    maxconn 4096 
    log local0 debug

   log global
   option httplog
   option dontlognull
   option forwardfor
   maxconn 20
   timeout connect 5s
   timeout client 5min60s
   timeout server 5min60s

frontend http-in
   bind *:80
   mode http
   acl prefixed-with-jenkins  path_beg /jenkins/
   acl host-is-jenkins-example   hdr(host) eq
   use_backend jenkins if host-is-jenkins-example prefixed-with-jenkins

backend jenkins
   server jenkins1
   mode http
   reqrep ^([^\ :]*)\ /(.*) \1\ /\2
   acl response-is-redirect res.hdr(Location) -m found
   rspirep ^Location:\ (http|https)://*) Location:\ \1://\2 if response-is-redirect



This assumes that you are using the /jenkins/ context path for both the site exposed from HAProxy, and Jenkins itself. If this is not the case, you will need to adjust the configuration.


If you are experiencing the following error when attempting to run long CLI commands in Jenkins > 2.80, and Jenkins is running behind HAProxy, it is probably due to HAProxy timing out the CLI connection. You can increase the timeout client and timeout server settings as necessary so the command will complete successfully. Versions of Jenkins before 2.80 might not respect the proxy_read_timeout setting.

No Format
Read back: 0x00 0x00 0x00 0x1e 0x07 'Started reverse-proxy-test #68' 0x00 0x00 0x00 0x01 0x07 0x0a
Read ahead: 
Diagnosis problem: Premature EOF
	at hudson.cli.FlightRecorderInputStream.analyzeCrash(
	at hudson.cli.PlainCLIProtocol$EitherSide$
Caused by: Premature EOF
	at hudson.cli.PlainCLIProtocol$EitherSide$

With SSL

Using HAProxy 1.7.9, here is an example HAProxy.cfg to connect to the proxy using SSL, terminate the SSL connection, and then talk to Jenkins using plain HTTP: