如何在haproxy tcp模式下将源ip设置为客户端ip

时间:2017-12-27 20:18:59

标签: haproxy

我正在使用haproxy将tcp流代理到我的tomcat后端。我想接收带有源IP地址作为客户端ip的流(而不是现在的127.0.0.1)。我已经设置了send-proxy选项(我正在使用haproxy 1.7.7),但它似乎没有什么区别。我做错了什么?

这是我的haproxy配置:

global
    log         127.0.0.1 local4

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

#------------------------------------------------------------------    
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    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 https
    mode tcp
    option tcp-smart-accept
    bind :::443 v4v6

    acl from_sa src 10.203.239.135
    use_backend tomcat-cp-events if from_sa
    default_backend apache

backend apache
    mode tcp
    option tcp-smart-connect
    server apache :50443 send-proxy

backend tomcat-cp-events
    mode tcp
    option tcp-smart-connect
    server tomcat :54600 send-proxy

0 个答案:

没有答案