提问人:Maxwell Arena 提问时间:11/18/2023 最后编辑:Maxwell Arena 更新时间:11/18/2023 访问量:35
如何修复 Jenkins 反向代理设置?
How to fix Jenkins reverse proxy setup?
问:
我正在寻找修复 Jenkins 的反向代理。症状如下:
- 配置页面显示我的反向代理已损坏
- 许多元素(测试结果、设置的某些部分)将无法加载
- 某些函数会导致此错误:
The URL you're trying to access requires that requests be sent using POST (like a form submission)
实际设置在 NAT 后面有一台 Jenkins 机器,以及一个运行 haproxy 的弹性 IP 的 AWS ec2。 它通常看起来像这样: Jenkins:8080 <-> EC2:8081 <-> haproxy <-> publicIP:443 <->我的浏览器
Jenkins 机器设置了到 ec2 的反向 ssh 隧道。 我的 haproxy 配置如下所示:
global
log 127.0.0.1 local0 notice
maxconn 2000
user haproxy
group haproxy
ssl-server-verify none
frontend cert
bind 0.0.0.0:80
bind 0.0.0.0:443 ssl crt /etc/ssl/certs/stunnel.pem
acl prefixed-with-jenkins path_beg /jenkins
http-request redirect scheme https unless { ssl_fc }
http-request redirect code 301 prefix /jenkins unless prefixed-with-jenkins
default_backend jenkins
backend jenkins
log stdout format raw local0 debug
mode http
server server1 localhost:8081 check
http-request replace-path /jenkins(/)?(.*) /\2
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request set-header X-Forwarded-Host %[req.hdr(Host)]
此外,haproxy 充当 SSL 终止符,如果配置文件中没有明确说明的话。
几乎所有这些配置选项都直接来自此处的 Jenkins 文档页面。我还使用 HTTPS 的自签名证书(称为 stunnel.pem,因为我先尝试过)
我错过了什么吗?如何支持 POST 方法?
答: 暂无答案
评论