【问题标题】:HAProxy: forward client ip (ssl traffic) to the backendHAProxy:将客户端 ip(ssl 流量)转发到后端
【发布时间】:2020-09-09 21:00:10
【问题描述】:

如果我将 SSL 流量发送到后端服务器,我可以在应用程序日志中看到客户端/源 IP。

ssl://host_name:8883

问题:如果我将 haproxy 放在后端服务器之前,我会得到 haproxy IP 作为源 IP。 SSL 终止发生在后端服务器。

haproxy.cfg:

defaults
    maxconn 64000
    option http-server-close
    option httplog
    option forwardfor
    option contstats
    timeout connect         5000ms
    timeout client          30000ms
    timeout server          30000ms
    timeout tunnel          3600000ms
    timeout http-keep-alive 1000ms
    timeout http-request    30000ms
    timeout queue           30000ms
    errorfile 504 /var/504.http

frontend tcp-frontend-mqtt-tls
    mode tcp
    bind :8883 accept-proxy
    log global
    log-format %ci\ %fi:%fp\ [%t]\ %ft\ %b/%s\ %Tw/%Tc/%Tt\ %B\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq
    tcp-request connection reject if { src -f /var/ip_blist.lst }
    default_backend tcp-backend-mqtt-tls

backend tcp-backend-mqtt-tls
    mode tcp
    log global
    balance leastconn
    source 0.0.0.0 usesrc clientip
    server mqtt-node-0 hostname:61008 resolvers my-dns check inter 1000

我尝试添加send-proxyv-v2send-proxy

server mqtt-node-0 hostname:61008 resolvers my-dns check inter 1000 send-proxy-v2
server mqtt-node-0 hostname:61008 resolvers my-dns check inter 1000 send-proxy

但这无济于事,因为 SSL 终止发生在后端。我错过了什么吗?

【问题讨论】:

    标签: ssl haproxy


    【解决方案1】:

    send-proxy 是一个很好的方法,但您的后端服务器/应用程序需要能够解析 PROXY 协议才能接收 IP 信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      • 2018-05-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多