linux

Centos - HAproxy + nginx

sysman 2021. 1. 7. 11:40

#############################

########server2에서...###########

#############################

 

[root@server2 ~]# dnf install haproxy

[root@server2 haproxy]# cp haproxy.cfg haproxy.old

[root@server2 haproxy]# setsebool -P haproxy_connect_any 1   //hpproxy 허용

[root@server2 haproxy]# firewall-cmd --permanent --add-port=80/tcp
[root@server2 haproxy]# firewall-cmd --reload

 

[root@server2 haproxy]# vi haproxy.cfg

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------

frontend http_balancer
    bind 192.168.10.210:80
    option http-server-close
    option forwardfor
    stats uri /haproxy?stats
     default_backend             app

 

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------

backend app

    mode http

    balance     roundrobin

    option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost

    server  server3.example.com 192.168.10.220:80 check

    server  server4.example.com 192.168.10.230:80 check

 

 

[root@server2 haproxy]# systemctl enable haproxy

[root@server2 haproxy]# systemctl restart haproxy 

[root@server2 haproxy]# systemctl status haproxy

 

 

#############################

########server3에서...###########

#############################

 

[root@server3 ~]# dnf -y install nginx

[root@server3 ~]# systemctl start nginx
[root@server3 ~]# systemctl enable nginx

 

[root@server3 html]# vi index.html

<p> first server.....</p>

 

[root@server3 ~]# cd /usr/share/nginx/html/

[root@server3 html]# firewall-cmd --permanent --add-service=http
[root@server3 html]# firewall-cmd --reload

 

#############################

########server4에서...###########

#############################

 

[root@server4 ~]# dnf -y install nginx 

[root@server4 ~]# systemctl start nginx 
[root@server4 ~]# systemctl enable nginx 

 

[root@server4 ~]# cd /usr/share/nginx/html/

[root@server4 html]# vi index.html

<p> second server.....</p>

 

[root@server4 html]# firewall-cmd --permanent --add-service=http 
[root@server4 html]# firewall-cmd --reload 

 

==============================================

t#############################

######## test 하기 ###########

#############################

 

 

반복 리프레시 하기

first server..... 와 second server.... 가 반복적으로 바뀜

'linux' 카테고리의 다른 글

centos 8 - galera + mariadb 설치  (0) 2021.01.07
centos 8 - rsyslog  (0) 2021.01.07
centos teaming - lacp  (0) 2021.01.06
centos 8 - gluster  (0) 2021.01.06
centos 8 - pacemaker + iscsi + gfs2 shared storage 이중화  (0) 2021.01.05