将带有自签名证书的请求发送到后端

Send request with self signed certificates to backend

Haproxy 文档 (http://cbonte.github.io/haproxy-dconv/1.7/intro.html#3.3.2) 列为基本功能:

authentication with the backend server lets the backend server it's really the expected haproxy node that is connecting to it

我一直在尝试这样做,但一直做不到。那么问题来了:

如何使用自签名证书向后端发送请求以进行身份​​验证。前端请求uses这个后端,就是http.

这是我的 haproxy.cfg 文件:

global
    maxconn 4096
    daemon
    log 127.0.0.1 local0

defaults
    log     global
    option  dontlognull
    retries 3
    option redispatch
    maxconn 2000
    timeout connect 5s
    timeout client  15min
    timeout server  15min

frontend public
    bind *:8213
    use_backend api if { path_beg /api/ }
    default_backend web

backend web
    mode http
    server blogweb1 127.0.0.1:4000

backend api
    mode tcp
    acl clienthello req.ssl_hello_type 1

    tcp-request inspect-delay 5s
    tcp-request content accept if clienthello

    server blogapi  127.0.0.1:8780

我终于开始工作了。我相信让我失望的是在执行 haproxy -f <configFile> -st 之后它实际上并没有像我想象的那样关闭进程。因此,我的 changes/updates 中的 none 接受了。我 kill -9 几十个 haproxy 服务并重新运行命令 (haproxy -f ),现在它正在工作。

现在,这是一个假设,尽管我非常有信心。我仍然会展示我的最终配置,以防有人从这里收集到一些东西。我用了https://www.haproxy.com/doc/aloha/7.0/deployment_guides/tls_layouts.html。 link 回答了我 "how do you authenticate to the backend using ssl" 的问题,就像文档说的那样。

global
    maxconn 4096
    daemon
    log 127.0.0.1 local0

defaults
    log     global
    option  dontlognull
    retries 3
    option redispatch
    maxconn 2000
    timeout connect 5s
    timeout client  15min
    timeout server  15min

frontend public
    bind *:443
    mode http
    use_backend api if { path_beg /api/ }

backend api
    mode http
    option httplog
    server blogapi  127.0.0.1:4430 ssl ca-file <caFile.Pem> crt <clientCert.pem> verify required