HAproxy 503 서비스를 사용할 수 없습니다. 이 요청을 처리할 수 있는 서버가 없습니다.

HAproxy 503 서비스를 사용할 수 없습니다. 이 요청을 처리할 수 있는 서버가 없습니다.

저는 이 로드 밸런싱 시나리오를 처음 접했고 이 로드 밸런싱을 작동시키는 방법을 알아내는 임무를 받았습니다.

내 환경:

Centos 6.4 64 Bit
Webserver: Lighttpd
All running in ESXI
virtual IP: 192.168.1.6
LB1: 192.168.1.4
LB2: 192.168.1.5
Webserver 1: 192.168.1.12
Webserver 2: 192.168.1.13
Gateway: 192.168.1.1

HAproxy 및 keepalived를 사용하여 프로덕션 전에 실험실에서 테스트를 실행하려고 합니다. Keepalived 설정에 대한 내용은 다음과 같습니다.

! 연결 유지를 위한 구성 파일

global_defs {
   notification_email {
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.1.4
   smtp_connect_timeout 30
   router_id 192.168.1.1
}

vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 1                     # check every second
weight 2                       # add 2 points of prio if OK
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 101  #priority 101 for master
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.6

    }

    track_script {
    chk_haproxy
            }

            }

HAproxy에 대한 설정은 다음과 같습니다.

#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    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

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
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

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend  main *:80
#    acl url_static       path_beg       -i /static /images /javascript /stylesheets
#    acl url_static       path_end       -i .jpg .gif .png .css .js

#    use_backend static          if url_static
#    default_backend             view

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
#backend static
#    balance     roundrobin
#    server      static 127.0.0.1:4331 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
mode tcp
    balance     roundrobin
    server  server1 192.168.1.12:80 check inter 2000 rise 2 fall 5
    server  server2 192.168.1.13:80 check inter 2000 rise 2 fall 5

HAproxy를 시작했을 때 이 오류가 발생했고 이를 해결하기 위해 어디서부터 시작해야 할지 잘 모르겠습니다. 아마도 이 일을 여러 번 해본 사람이 내가 약간의 빛을 밝히는 데 도움을 줄 수 있을까요?

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

그러나 webserver1 및 webserver2에 수동으로 연결하면 정상적으로 작동합니다.

내가 원하는 것은 HAproxy 뒤에 있는 웹 서버에 대한 간단한 로드 밸런싱뿐입니다. 어떤 조언이나 제안이라도 진심으로 감사드립니다. 도와주세요? 많은 감사를 드립니다.

답변1

default_backend app나는 HAproxy를 사용한 적이 없지만 빠른 검색을 통해 바로 아래에 추가해야 한다고 생각하게 됩니다 frontend main *:80. 백엔드와 프론트엔드를 함께 연결하는 구성에서는 어디에도 없습니다.

답변2

HAProxy 구성에 문제가 있습니다. 구성에서 모든 주석을 제거하면 다음과 같은 결과가 나타납니다.

global
  log         127.0.0.1 local2

  chroot      /var/lib/haproxy
  pidfile     /var/run/haproxy.pid
  maxconn     4000
  user        haproxy
  group       haproxy
  daemon

  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  main *:80

backend app
  mode tcp
  balance roundrobin
  server  server1 192.168.1.12:80 check inter 2000 rise 2 fall 5
  server  server2 192.168.1.13:80 check inter 2000 rise 2 fall 5

이제 프런트엔드 구성이 전혀 없다는 것을 확실히 알 수 있습니다. 요청은 다음을 통해 HAProxy로 전달되지만 frontend mainHAProxy는 어떤 서버가 이를 처리할 수 있는지 알지 못하므로 503을 반환합니다.

acl을 사용하거나 사용하여 백엔드를 프런트엔드에 연결해야 합니다 default_backend.

소켓뿐만 아니라 보호된 웹 인터페이스에서도 통계를 사용해야 합니다. haproxy 뒤의 클러스터, 오프라인 상태인 서버, 문제가 있는 서버, 응답 시간 등에 대한 정보를 보여줄 수 있습니다. 디버깅에 매우 유용합니다.

답변3

HAProxy가 기본 상태 확인으로 인해 내 백엔드가 다운되었다고 생각했기 때문에 비슷한 오류가 발생했습니다. 상태 점검을 비활성화했더니 503이 사라졌습니다.

나는 pfsense GUI를 사용하고 있습니다. 여기에 이미지 설명을 입력하세요

답변4

PFSense는 TLS 인증서를 사용할 때 기본적으로 추가 ACL을 자동으로(그리고 다소 눈에 띄지 않게) 추가합니다. '추가 인증서' 섹션을 사용하여 두 번째 가상 호스트와 두 번째 인증서를 추가했습니다. 이로 인해 기본 인증서 ACL이 그대로 유지되었습니다.

이러한 ACL을 비활성화하고 다시 시작하면 문제가 해결됩니다.

여기에 이미지 설명을 입력하세요

관련 정보