把后端服务器IP(192.168.1.2, 192.168.1.3, 192.168.1.4)加到backend里
- #---------------------------------------------------------------------
- # Global settings
- #---------------------------------------------------------------------
- global
- log 127.0.0.1 local2
-
- chroot /var/lib/haproxy
- pidfile /var/run/haproxy.pid
- maxconn 4096
- user haproxy
- group haproxy
- daemon
-
- # turn on stats unix socket
- stats socket /var/lib/haproxy/stats
-
- listen stats
- bind *:9000
- mode http
- stats enable
- stats hide-version
- stats uri /stats
- stats refresh 30s
- stats realm Haproxy Statistics
- stats auth admin:admin
-
-
- frontend k8s-api
- bind *:443
- mode tcp
- option tcplog
- tcp-request inspect-delay 5s
- tcp-request content accept if { req_ssl_hello_type 1 }
- default_backend k8s-api-backend
-
- backend k8s-api-backend
- mode tcp
- option tcplog
- option tcp-check
- balance roundrobin
- server master1 192.167.1.2:80 maxconn 1024 weight 5 check
- server master2 192.167.1.3:80 maxconn 1024 weight 5 check
- server master3 192.167.1.4:80 maxconn 1024 weight 5 check
2.5 配置nginx
给nginx添加SSL证书,配置过程略
- vi /usr/share/nginx/html/index.html
把index.html里面字符串Welcome to nginx改成Welcome to nginx HA
3 启动服务
3.1 启动nginx
- sudo systemctl start nginx
- sudo systemctl enable nginx
3.2 启动haproxy
- sudo systemctl start haproxy
- sudo systemctl enable haproxy
(编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|