1. # cd /usr/local/haproxy
    2. # vi haproxy.cfg
    3. global
    4. maxconn 51200
    5. chroot /usr/local/haproxy
    6. uid 99
    7. gid 99
    8. daemon
    9. #quiet
    10. nbproc 1
    11. pidfile /usr/local/haproxy/logs/haproxy.pid
    12. defaults
    13. mode http
    14. #retries 2
    15. option redispatch
    16. option abortonclose
    17. timeout connect 5000ms
    18. timeout client 30000ms
    19. timeout server 30000ms
    20. #timeout check 2000
    21. log 127.0.0.1 local0 err #[err warning info debug]
    22. balance roundrobin
    23. # option httplog
    24. # option httpclose
    25. # option dontlognull
    26. # option forwardfor
    27. listen admin_stats
    28. bind 0.0.0.0:8888
    29. option httplog
    30. stats refresh 30s
    31. stats uri /stats
    32. stats realm Haproxy Manager
    33. stats auth admin:admin
    34. #stats hide-version
    35. listen test1
    36. bind :12345
    37. mode tcp
    38. server t1 127.0.0.1:8881
    39. server t2 192.168.1.102:8881
    40. listen test2 :80
    41. option httpclose
    42. option forwardfor
    43. server s1 127.0.0.1:8081 check weight 1 minconn 1 maxconn 3 check inter 40000
    44. server s2 127.0.0.1:8082 check weight 1 minconn 1 maxconn 3 check inter 40000