HAProxy 实践(一)

运行环境

OS: Deiban 7
软件:haproxy 1.5.8

HTTP Server:
192.168.99.1:8520
192.168.99.1:8530
192.168.99.1:8540
192.168.99.1:8550

MySQL Server:
192.168.99.1:3306

按照该配置在命令行下执行

#可能需要管理员权限
sudo haproxy -d -f ./haproxy.cfg

HTTP访问地址

http://localhost:8081

MySQL访问地址

数据库代理访问未测试

localhost:3306

配置内容

#file haproxy.cfg
lobal
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        pidfile /var/run/haproxy.pid
        maxconn 4096
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
        daemon
        nbproc 1

        # 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). This list is from:
        #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
        ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
        ssl-default-bind-options no-sslv3

# common defaults that all the ‘listen’ and ‘backend’ sections will
# use if not designated in their block

defaults
        log     global
#       mode    http
        mode    tcp
#       option  httplog
        option  tcplog
        option  dontlognull
        option  redispatch      
        retries 3
        timeout http-request 10s
        timeout connect 1m
        timeout connect 10s
        timeout client 1m 
        timeout server 1m 
        timeout http-keep-alive 10s 
        timeout check 10s 
        maxconn 3000
        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

listen mysql_proxy :3306
        mode    tcp
        balance roundrobin
        server  mysql_1 192.168.99.1:3306 check inter 5000 rise 2 fall 3
        server  mysql_2 192.168.99.1:3306 check inter 5000 rise 2 fall 3

listen http_proxy :8081
        mode    http
        option  httplog
        stats   enable
        stats   uri       /stats
        stats   refresh   5s
        server  php_52 192.168.99.1:8520 check inter 5000 rise 2 fall 3
        server  php_53 192.168.99.1:8530 check inter 5000 rise 2 fall 3
        server  php_54 192.168.99.1:8540 check inter 5000 rise 2 fall 3
        server  php_56 192.168.99.1:8560 check inter 5000 rise 2 fall 3
posted @   卜木  阅读(264)  评论(0编辑  收藏  举报
编辑推荐:
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 互联网不景气了那就玩玩嵌入式吧,用纯.NET开发并制作一个智能桌面机器人(三):用.NET IoT库
· 【非技术】说说2024年我都干了些啥
点击右上角即可分享
微信分享提示