haproxy redireciona o pedido ip para o ip / caminho

1

Eu tenho um nó haproxy e 3 servidores de aplicativos (tomcat) por trás dele. Os usuários devem abrir http://10.0.0.1 (por endereço IP) e, em seguida, ser redirecionados para http://10.0.0.2/app ou http://10.0.0.3/app ou http://10.0.0.4/app .

Configuração atual do haproxy:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    chroot /var/lib/haproxy
    user haproxy
    group haproxy
    daemon
    maxconn 50000
defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
#       option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
    retries 3
    redispatch
    contimeout 1s
    clitimeout 2s
    srvtimeout 3s
    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
    listen stats :1941
    mode http
    stats enable
    stats hide-version
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth xxx:xxx
listen appfarm 10.0.0.1:80
    mode http
    stats enable
    stats auth xxx:xxx
    balance source
    hash-type consistent
    option httpclose
    option forwardfor
#   option httpchk HEAD /check.txt HTTP/1.0
    server app01 10.0.0.2:8080/app check
    server app02 10.0.0.3:8080/app check
    server app03 10.0.0.4:8080/app check

Com essa configuração, recebi a página de boas-vindas do tomcat do endereço 10.0.0.1:8080, sem / app in address.

    
por Alex P 20.07.2016 / 13:38

1 resposta

2

Você não pode adicionar um caminho na linha do servidor assim, você vai querer usar um redirecionamento no seu bloco de escuta acima das linhas do servidor:

redirect location /app if { url / }

e converta suas linhas de servidor para

server app01 10.0.0.2:8080 check

Consulte o link para mais explicações / exemplos, e observe que este exemplo está usando ACLs anônimas que podem obter o kludgy com configurações maiores.

    
por 20.07.2016 / 14:33

Tags