使用haproxy 1.7.9,这里是一个例子haproxy.cfg在普通http上代理:
#如果你已经有一个haproxy.cfg文件,你可以保留# global和defaults部分,但是你可能需要增加# timeout,这样长时间运行的CLI命令才能工作。4096年全球maxconn日志127.0.0.1 local0调试违约记录全球选择httplog选项dontlognull选项forwardfor maxconn 20超时连接5 s超时60年代60年代客户机超时服务器前端http绑定*:80模式http acl prefixed-with-jenkins path_beg / jenkins / acl host-is-jenkins-example hdr(主机)情商jenkins.example.com use_backe必威国际有限公司nd詹金斯如果host-is-j必威国际有限公司enkins-example prefixed-with-jenkins端詹金斯服务器jenkins1 127.0.0.1:8080 http reqrep模式 ^([^\ :]*)\ /(.*) \ 1 \ \ 2 acl response-is-redirect res.hdr(位置)- m发现#必须将下面两行合并到一行的HAProxy rspirep ^位置:\ (http | https): / / 127.0.0.1:8080 / jenkins /(. *)位置:\/ / j必威国际有限公司enkins.example.com/jenkins/ \ \ 1:如果response-is-redirect 2
这假设Jenkins在本地必威国际有限公司端口8080上运行。
这假设您正在使用从Haproxy公开的网站和Jenkins本身的网站的/ 必威国际有限公司jenkins / context路径。如果不是这种情况,您需要调整配置。
如果尝试在Jenkins运行Long CLI命令时遇到以下错误,并且Jenkins正在落后于HAProxy,则可能是由于HAProxy时机CLI连接。必威国际有限公司你可以增加超时客户
和超时服务器
设置如有必要,因此命令将成功完成。
警告:null hudson.cli.diagnosedstreamcorruptionexception read:0x00 0x00 0x00 0x1e 0x07'启动反向代理测试#68'0x00 0x00 0x00 0x01 0x07 0x0a阅读前方:诊断问题:java.io.ioexception:sun.net早产。www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:565) ... at hudson.cli.FlightRecorderInputStream.analyzeCrash(FlightRecorderInputStream.java:82) at hudson.cli.PlainCLIProtocol$EitherSide$Reader.run(PlainCLIProtocol.java:153) Caused by: java.io.IOException: Premature EOF at sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:565) ... at java.io.DataInputStream.readInt(DataInputStream.java:387) at hudson.cli.PlainCLIProtocol$EitherSide$Reader.run(PlainCLIProtocol.java:111)