
HAProxy와 Apache 사이에 Varnish를 넣을 생각입니다. 작동 중이지만 HAProxy 사이에 Varnish가 있으면 Varnish를 모니터링하고 있습니다. Apache가 다운되면 다른 Apache로 장애 조치되지 않습니다.
이 문제를 극복할 수 있는 구성이 HAProxy에 있습니까?
답변1
Varnish가 HAproxy와 Apache 사이에 있는 경우 Varnish가 해당 작업을 수행하도록 할 수 있습니다.로드 밸런싱, HAproxy에서 제공하는 옵션만큼 강력하지는 않습니다.
HAproxy가 정적 콘텐츠를 Varnish로 보내고 나머지는 백엔드 서버로 직접 보내도록 하는 것이 더 좋을 수 있습니다.
Haproxy.com에는 수행 방법에 대한 매우 좋은 기사가 있습니다.여기.
HAproxy가 Varnish의 상태를 확인하도록 하려는 경우그리고동시에 Apache(동일한 호스트에 있음)에는 두 가지 옵션이 있습니다.
Apache를 확인하고 일치하는 Varnish 서버가 더미를 추적하도록 HAProxy에 더미 백엔드/서버를 설정합니다.
frontend HTTP-IN mode http default_backend Varnishes # All traffic goes here backend Varnishes mode http balance roundrobin server Varnish-1 1.1.1.1:80 track Apache-1/Apache-1 server Varnish-2 2.2.2.2:80 track Apache-2/Apache-2 # No traffic ever goes here # Just used for taking servers out of rotation in 'backend Varnishes' backend Apache-1 server Apache-1 1.1.1.1:8080 check backend Apache-2 server Apache-2 2.2.2.2:8080 check
Varnish가 Apache의 상태와 일치하는 상태 확인 결과를 반환하도록 합니다(Apache가 작동 중이면 OK, 그렇지 않으면 FAILED).
varnish.vcl
backend default { .host = "127.0.0.1"; .port = "8080"; } # Health Check if (req.url == "/varnishcheck") { if (req.backend.healthy) { return(synth(751, "OK!")); } else { return(synth(752, "FAILED!")); } } sub vcl_synth { # Health Checks if (resp.status == 751) { set resp.status = 200; return (deliver); } if (resp.status == 752) { set resp.status = 503; return (deliver); } }
haproxy.cfg
frontend HTTP-IN mode http default_backend Varnishes backend Varnishes mode http balance roundrobin option httpchk HEAD /varnishcheck http-check expect status 200 server Varnish-1 1.1.1.1:80 check server Varnish-2 2.2.2.2:80 check