都关闭防火墙和selinux以防测试出问题
172.30.2.110(http1):
yum install -y httpd
vi /var/www/html/index.html
aaaa
:wq
sytemctl start httpd
systemctl enable httpd
172.30.2.111(http2):
yum install -y httpd
vi /var/www/html/index.html
bbbb
:wq
systemctl start httpd
systemctl enable httpd
172.30.2.112(nginx):
yum install -y nginx
vi /etc/nginx/nginx.conf
upstream myserv {
server 172.30.2.110:80;
server 172.30.2.111:80;
}
location /
{
proxy_pass http://myserv;
}
:wq
nginx -t
systemctl start nginx
systemctl enable nginx
ssl:
yum install -y gcc make zlib-devel pcre pcre-devel openssl-devel
mkdir /etc/pki/CA
umask 077; openssl genrsa -out /etc/pki/CA/cakey.pem 4096
openssl req -new -x509 -key /etc/pki/CA/cakey.pem -out /etc/pki/CA/cacert.pem -days 3655
vi /etc/nginx/nginc.conf
#把66到结尾的#去掉
ssl_certificate "/etc/pki/CA/cacert.pem";
ssl_certificate_key "/etc/pki/CA/cakey.pem";
#在443的server下再次写入代理
location / {
proxy_pass http://myserv;
}
:wq
nginx -t
systemctl restart nginx
参考自https://www.runoob.com/w3cnote/nginx-proxy-balancing.html