HAProxy 역방향 프록시 구성

HAProxy 역방향 프록시 구성

일부 웹사이트를 새 서버로 마이그레이션하고 싶습니다. 모든 DNS 변경을 완료하는 데 며칠이 걸리기 때문에 HAProxy 역방향 프록시를 설정하여 모든 트래픽을 이전 위치에서 새 위치로 리디렉션하고 싶었습니다. 나는 그러한 구성에 대한 경험이 많지 않습니다. 도메인을 방문할 때 다음과 같은 오류가 발생합니다.

503 Service Unavailable No server is available to handle this request.

이것은 내가 사용한 구성입니다(숨겨진 IP 주소 포함).

global

  log         127.0.0.1 local2

    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

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 localhost
   bind *:80
   bind *:443 ssl crt /etc/pki/tls/certs/haproxy.pem
   redirect scheme https if !{ ssl_fc }
   mode http
   default_backend node

backend node
    mode http
    option forwardfor
    option httpchk HEAD / HTTP/1.1\r\nHost:localhost
    server dcnode1 x.x.x.x:80 check
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }

답변1

이 오류는 백엔드가 '작동'된 것으로 간주되지 않음을 의미합니다.

먼저 백엔드 서버가 실행 중이고 HAProxy 시스템에서 액세스할 수 있는지 확인 telnet x.x.x.x 80하고 연결되는지 확인하세요.

연결에 성공했다면 두 번째로 확인해야 할 것은 백엔드가 확인에 실패했는지 여부입니다. 제거를 시도하고 라인 에서 option httpchk제거하십시오 . (백엔드 서버가 하나만 있는 경우 확인은 큰 가치가 없지만 나중에 언제든지 다시 추가할 수 있습니다.)checkserver

Host: localhost귀하가 수표에 특이한 것을 반환하고 있을 수도 있습니다 .

관련 정보