【发布时间】:2020-12-21 07:56:52
【问题描述】:
我有一个来自客户端的 nginx,我可以通过以下方式成功发布:
curl -v --cacert ca.crt --cert client.crt --key client.key -POST https://nginx:8443/api/ -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d@test.json
现在我在 nginx 前面安装了一个 haproxy,我正在尝试以同样的方式进行 POST,但不成功:
curl -v --cacert ca.crt --cert client.crt --key client.key -POST http://haproxy:8443/api/ -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d@test.json
错误:
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx</center>
这是我的 haproxy 配置:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode tcp
log global
option tcplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend main *:8443
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
backend static
balance roundrobin
server static 127.0.0.1:8443
backend app
mode tcp
balance roundrobin
server nginx nginx01:8443
我想通过 HAProxy 转发 SSL 流量并将用于身份验证的证书传递给 nginx。 我知道拥有两个 LB 没有任何意义,但我无法修改 nginx 和后面的 api 服务器,但客户端将是内部的。 正如您在这一点上看到的,我可以访问 nginx,但 haproxy 不会将证书和密钥从请求传递到 nginx 后端。 我错过了什么吗?这是我能做到的吗?
ps:如果我在后端设置“ssl verify none”,我会得到“没有发送所需的 SSL 证书”。 如果我在后端设置“send-proxy”,我会从 nginx 收到“400 Bad Request”。
【问题讨论】: