haproxy 安装和配置

来源:互联网 发布:影视先锋mac 编辑:程序博客网 时间:2024/05/18 08:33
<pre name="code" class="sql"><pre name="code" class="sql">yum -y install  gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses* libmcrypt* # tar zcvf haproxy-1.3.20.tar.gz# cd haproxy-1.3.20# make TARGET=linux26 PREFIX=/usr/local/haproxy                                #将haproxy安装到/usr/local/haproxy# make install PREFIX=/usr/local/haproxyjrhppt01:/root# ps -ef | grep haproxyroot     11889 11871  0 10:33 pts/0    00:00:00 grep haproxyhaproxy  31872     1  0 Apr16 ?        02:09:08 /usr/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid启动程序:haproxy:/usr/local/haproxy/sbin# lshaproxy  haproxy-systemd-wrapper配置文件路径:/etc/haproxy配置内容:# this config needs haproxy-1.1.28 or haproxy-1.2.1globallog 127.0.0.1local3 maxconn 65535 chroot /usr/local/haproxyuid 401gid 401 daemondefaultslogglobalmodehttpoptionhttplogoptiondontlognullretries3option  redispatchoption  abortonclose option  httpcloseoption  forwardformaxconn 65535timeout connect 5000timeout client  50000timeout server 50000timeout check   5sstats   refresh 30sstats   uri     /statsstats   realm   baison-test-Haproxy       stats   auth    admin:zjadmin818  stats   hide-version            frontend  wwwbind            *:80        bind            *:443      ssl                     crt                     /etc/haproxy/cert.pem  redirect scheme https if !{ ssl_fc }acl host_zjcap.cn  hdr_beg(host)  -i zjcap.cn         redirect prefix   http://www.zjcap.cn if host_zjcap.cn####flow        acl             web_req                 path_beg                -i                      /web        use_backend     appserver_8081          if                      web_req        ####flow        acl             business_req            path_beg                -i                      /business        use_backend     appserver_8081          if                      business_req        acl             validcode_req           path_beg                -i                      /validcode        use_backend     appserver_8081          if                      validcode_req        ####api        acl             api_req                 path_beg                -i                      /api        use_backend     appserver_8082          if                      api_req        ###web nginx        acl             mgr_req                 path_beg                -i                      /backoffice        use_backend     mgrserver_8001          if                      mgr_req        ###pay        acl             pay_req                 path_beg                -i                      /pay        use_backend     appserver_8083          if                      pay_req        acl             llmock_req              path_beg                -i                      /llmock        use_backend     appserver_8083          if                      llmock_req       ###web         acl             url_static              path_end                .html .gif .png .jpg .css .js        use_backend     webserver_8001          if                      url_static        default_backend webserver_8001###frond endbackendwebserver_8001mode    httpbalanceroundrobinserver  webhost01_800110.252.105.157:8001     check inter 2000 fall 3 server  webhost02_800110.168.29.17:8001       check inter 2000 fall 3 ####backofficebackendmgrserver_8001mode    httpserver  mgrhost_800110.168.34.94:8001       check inter 2000 fall 3 ######flowbackend appserver_8081        mode http        balance roundrobin        server  apphost01_8081 10.168.32.82:8081check inter 2000 fall 3        server  apphost02_8081 10.168.33.193:8081  check inter 2000 fall 3######apibackend appserver_8082        mode http        balance roundrobin        server  apphost11_8082 10.171.243.55:8082  check inter 2000 fall 3        server  apphost12_8082 10.252.148.164:8082  check inter 2000 fall 3#######paybackend appserver_8083        mode http        balance roundrobin        server  apphost21_8083 10.171.240.139:8083  check inter 2000 fall 3        server  apphost22_8083 10.252.163.244:8083  check inter 2000 fall 3listen stats 0.0.0.0:8899       mode http       option httpclose       balance roundrobin       stats uri /admin-status       stats realm Haproxy\ Statistics       stats auth admin:admin-check简单测试:        acl             api_req                 path_beg                -i                      /api        use_backend     appserver_8082          if                      api_req         acl             url_static              path_end                .html .gif .png .jpg .css .js        use_backend     webserver_8001          if                      url_static        default_backend webserver_8001        backend appserver_8082        mode http        balance roundrobin        server  apphost11_8082 10.171.243.55:8082  check inter 2000 fall 3        server  apphost12_8082 10.252.148.164:8082  check inter 2000 fall 3                backendwebserver_8001mode    httpbalanceroundrobinserver  webhost01_800110.252.105.157:8001     check inter 2000 fall 3 server  webhost02_800110.168.29.17:8001       check inter 2000 fall 3 haproxy:192.168.32.173 http://192.168.32.173/api --可以访问http://192.168.32.173/ --跳到静态页


                                             
0 0
原创粉丝点击