haProxy:如何在URL中保留haproxy IP

时间:2018-10-08 05:18:43

标签: haproxy

我用两个后端服务器Y和Z设置了haproxy -X

我的问题是,当我调用X(haproxy)时,它可以正确地重定向到Y或Z,但URL也已更改(包含Y或Z IP),所以现在我直接与WebServer通讯,而不是haProxy Server。

是否可以在请求中保留haProxy IP?

haproxy.cfg

    global
    log 127.0.0.1 local0
    maxconn 2000
  user haproxy
  group haproxy

defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
        contimeout 5000
        clitimeout 50000
        srvtimeout 50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend LB
   bind *:80
   reqadd X-Forwarded-Proto:\ http
   option   httplog
   default_backend LB

backend LB
   mode http
   stats enable
   stats hide-version
   stats uri /stats
   stats realm Haproxy\ Statistics
   stats auth haproxy:redhat        # Credentials for HAProxy Statistic report page.
   balance roundrobin           # Load balancing will work in round-robin process.
   option httpchk
   option  httpclose
   option forwardfor
   option   httplog
   cookie LB insert
   server web1-srv 10.164.29.225:80 cookie web1-srv check       # backend server.
   server web2-srv 10.164.27.31:80 cookie web2-srv check        # backend server.

0 个答案:

没有答案