HTTP의 내부 URL을 사용하여 301을 각 서버로 리디렉션해야 하는 두 개의 백엔드 서버가 있는 구성이 있습니다. 해당 구성에서는 보고서 서버에 SSL을 설치할 수 없기 때문에 SSL을 사용하기가 어렵습니다. 또한 보고서를 볼 때 보고서 뷰어에 내부 문제가 있기 때문에 가상 도메인 및 공유 IP를 사용하여 트래픽을 리디렉션할 수 없습니다. 내부 URL을 사용하여 트래픽을 백엔드 서버로 리디렉션하면 되지만 IP도 괜찮습니다.
현재 나는 하나의 특정 호스트에 대해 수행하는 방법을 알고 있지만 현재 서버에는 수행할 수 없습니다.
구성: 백엔드에 대한 활성/수동 구성입니다.
HA-프록시 버전 2.0.29-0ubuntu1
우분투 20.04.5 LTS
Keepalived v2.0.19
frontend raporty bind 192.168.0..108:80 bind 192.168.0.108:443 ssl crt /etc/ssl/certs/haproxy.pem default_backend reportserver option forwardfor backend reportserver mode http balance roundrobin option httpchk uri /reports http-check expect status 401 http-response set-header X-Server %s http-request redirect code 301 location http://sql02.domain.local%[capture.req.uri] server sql01 192.168.0.11:80 check check fall 5 server sql02 192.168.0.111:80 check check fall 5 http-response set-header X-Server %s
답변1
이는 ACL 및 srv_is_up 매개변수를 사용하여 관리되었습니다.
frontend raporty
bind 192.168.0.108:80
bind 192.168.0.108:443 ssl crt /etc/ssl/certs/haproxy.pem
http-response set-header X-Server %s
http-response set-header Host %s
default_backend reportserver
option forwardfor
backend reportserver
mode http
balance roundrobin
option httpchk uri /reports
http-check expect status 401
acl asql01 srv_is_up(reportserver/sql01)
acl asql02 srv_is_up(reportserver/sql02)
http-request set-header Host %s
http-response set-header Host %s
http-request redirect code 301 location http://sql01.domain.local%[capture.req.uri] if asql01
http-request redirect code 301 location http://sql02.domain.local%[capture.req.uri] if asql02
server sql01 sql01.domain.local:80 check check fall 5
server sql02 sql02.domain.local:80 check check fall 5
http-response set-header X-Server %s