HAProxy Url 패턴 전달

HAProxy Url 패턴 전달

저는 두 개의 웹 서버(HTTP 모드)의 로드 밸런싱을 위해 HAProxy를 사용하고 있습니다. 웹 서버는 엄격하게 동적입니다. 즉, 정적 콘텐츠는 없고 웹 서비스만 있습니다.
해당 유형의 URL(유사)

http://192.168.5.10:8080/small
http://192.168.5.10:8080/medium
http://192.168.5.10:8080/large

acl이제 몇 대의 컴퓨터에서 이러한 3개의 URL로 들어오는 요청을 전달하도록 HAProxy를 구성할 때 및 path_end/를 사용하여 url_path를 지정 path_beg하지만 요청을 하면 Not Found on Accelerator오류가 발생하여 문제를 정확히 지적하기가 더 어려워집니다.

아래는 제가 사용하고 있는 구성입니다. 또한 오류가 기록되지 않습니다.

    global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        maxconn 4096
        user haproxy
        group haproxy
        daemon

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      10000
        srvtimeout      10000

frontend http_proxy
        bind 192.168.5.9:8888
        acl is_small path_end -i small
        acl is_medium path_end -i medium
        acl is_large path_end -i large

        use_backend web_server_small if is_small
        use_backend web_server_medium if is_medium
        use_backend web_server_large if is_large

backend web_server_small
        mode http
        balance roundrobin
        option httpclose
        server  web_1 192.168.5.10:8080 check
        server  web_2 192.168.5.11:8080 check

backend web_server_medium
        mode http
        balance roundrobin
        option httpclose
        server  web_1 192.168.5.12:8080 check
        server  web_2 192.168.5.13:8080 check

backend web_server_large
        mode http
        balance roundrobin
        option httpclose
        server  web_1 192.168.5.14:8080 check
        server  web_2 192.168.5.15:8080 check

url_path를 사용하여 HAProxy에서 web_server로 요청을 보낼 수 있습니까?.

HAProxy가 이를 수신하면 http://192.168.5.2:80/small다음과 같이 웹 서버에 요청을 보냅니다.http://192.168.5.10:8080/small

답변1

경로가 URL 시작 부분에 포함되어 있으므로 path_beg를 사용하지 않는 것이 좋습니다. path_end의 권장 사용은 파일 이름 확장자입니다.

        acl is_small path_beg -i /small
        acl is_medium path_beg -i /medium
        acl is_large path_beg -i /large

답변2

HTTP 요청의 경로는 다음과 같습니다.언제나백엔드 서버로 전달됩니다. 즉,

GET /small HTTP/1.1

해당 요청으로 HAproxy 뒤에 표시됩니다. 이것이 어떻게 든 잘린 것으로 의심되는 경우

GET / HTTP/1.1

HAproxy 뒤의 서버에서 다음을 사용하여 이를 확인해야 합니다.

tcpdump -i any port 8080 -As1024 | grep GET

해당 서버에서 인바운드 GET요청을 지켜보세요.

나는 사지에 갈 것이고 당신이 HAproxy를 기대한다고 가정합니다.끼워 넣다URI 앞에 뭔가가 있습니다.

    server web_1 192.168.5.14:8080/my/path check

에 대한 요청 /small이 에 대한 요청으로 바뀔 것입니다 /my/path/small. 이는 옵션을 사용하여 달성할 수 있습니다 reqrep.선적 서류 비치자세한 내용은.

관련 정보