如何在Haproxy

时间:2017-07-08 13:52:41

标签: haproxy

我正在尝试在haproxy中为我的java Rest Services传递基于user_id的动态值。

本地主机:/ AAA / BBB / {用户ID}

以下声明是示例

localhost:/ AAA / BBB / 1

本地主机:/ AAA / BBB / 2

本地主机:/ AAA / BBB / 3

我想通过haproxy传递它。我有以下配置..

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL).
    ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4- SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL

默认

     log     global
     mode    http
     option  httplog
     option  dontlognull
     timeout connect 5000
     timeout client  50000
    timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

前端http

bind *:80    
acl msg-listing-read path_end -i /AAA/BBB/{user_id}
use_backend ppl-be-msg-listing-read-dev if msg-listing-read

backend ppl-be-msg-listing-read-dev

balance roundrobin
server ppl-msg-listing-read-dev localhost:8080 maxconn 32 check

收听统计数据

bind 0.0.0.0:81
stats enable
stats uri /

任何想法都将受到赞赏,并提前致谢。

0 个答案:

没有答案