2015-01-28 2 views
0

API 웹 서버가 있습니다. 두 가지 버전의 api가 공존하며, URL 경로 (/ shine/v7 및/shine/v8)로 라우팅됩니다.Haproxy URL 경로가 작동하지 않습니다.

나는 이것을 haproxy로 만들었지 만,/shine/v7/admin을 요청할 때 때때로 shine_v8_backend에 갔다가 때로는 shine_v7_backend로 갔다. 왜 이런 일이 일어 났는지 아무도 알지 못한다.

나는/광택/V7/admin을 여러 번 요청하려고 내 haproxy.conf

global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    maxconn 4096 
    daemon 

defaults 
    log  global 
    option http-server-close 

frontend http *:5000 
    mode tcp 
    timeout client 86400000 

    default_backend shine_v8_backend 
    acl shine_v7 path_dir /shine/v7 
    use_backend  shine_v7_backend if shine_v7 


backend shine_v8_backend 
    mode tcp 
    option httpclose 
    balance roundrobin 
    timeout server 86400000 
    timeout connect 5000 
    server host_0 127.0.0.1:5001 

backend shine_v7_backend 
    mode tcp 
    option httpclose 
    balance roundrobin 
    timeout server 86400000 
    timeout connect 5000 
    server host_0 127.0.0.1:5002 

이, '그것은 할 수있는, 내가 문제를 발견

$ sudo haproxy -f haproxy.conf -d 
Available polling systems : 
    kqueue : pref=300, test result OK 
     poll : pref=200, test result OK 
    select : pref=150, test result FAILED 
Total: 3 (2 usable), will use kqueue. 
Using kqueue() as the polling mechanism. 
00000000:http.accept(0004)=0006 from [127.0.0.1:55026] 
00000000:shine_v7_backend.srvcls[0006:0007] 
00000000:shine_v7_backend.clicls[0006:0007] 
00000000:shine_v7_backend.closed[0006:0007] 
00000001:http.accept(0004)=0006 from [127.0.0.1:55028] 
00000001:shine_v8_backend.srvcls[0006:0007] 
00000001:shine_v8_backend.clicls[0006:0007] 
00000001:shine_v8_backend.closed[0006:0007] 
00000002:http.accept(0004)=0006 from [127.0.0.1:55030] 
00000002:shine_v7_backend.srvcls[0006:0007] 
00000002:shine_v7_backend.clicls[0006:0007] 
00000002:shine_v7_backend.closed[0006:0007] 
00000003:http.accept(0004)=0006 from [127.0.0.1:55032] 
00000003:shine_v8_backend.srvcls[0006:0007] 
00000003:shine_v8_backend.clicls[0006:0007] 
00000003:shine_v8_backend.closed[0006:0007] 
00000004:http.accept(0004)=0006 from [127.0.0.1:55034] 
00000004:shine_v7_backend.srvcls[0006:0007] 
00000004:shine_v7_backend.clicls[0006:0007] 
00000004:shine_v7_backend.closed[0006:0007] 

답변

0

로그가 여기 t 사용 모드 TCP는, 모드에 http :(사용해야합니다

및 수정 후

는 haproxy.conf는

global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    maxconn 4096 
    daemon 

defaults 
    log  global 
    mode http 
    option httplog 
    option dontlognull 
    option forwardfor 
    option http-server-close 

frontend http *:5000 
    timeout client 86400000 

    acl shine_v8 path_dir /shine/v8 
    acl shine_v7 path_dir /shine/v7 

    use_backend  shine_v8_backend if shine_v8 
    use_backend  shine_v7_backend if shine_v7 

backend shine_v8_backend 
    option httpclose 
    balance roundrobin 
    timeout server 86400000 
    timeout connect 5000 
    server host_0 127.0.0.1:5001 

backend shine_v7_backend 
    option httpclose 
    balance roundrobin 
    timeout server 86400000 
    timeout connect 5000 
    server host_0 127.0.0.1:5002 
입니다

잘 작동합니다.