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現在、HAProxy を設定して、着信リクエストを数台のマシン上のこれら 3 つの URL に転送するときに、と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 パス_beg -i /small
        acl is_medium パス_beg -i /medium
        acl is_large パス_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ドキュメンテーション詳細については。

関連情報