Realize reverse proxy load balancing through nginx
cd /root/nginx-1.19.1/auto/cc
vim gcc
cd /root/nginx-1.19.1/src/core/
vim nginx.h 隐藏版本
cd /usr/local/nginx/sbin
./nginx
cd /usr/local/nginx/logs
ls 启动nginx后查找其pid文件位置
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin 添加软连接
cd /lib/systemd/system
vim nginx.service 编辑nginx启动脚本
systemctl daemon-reload
vim /etc/security/limits.conf
useradd -M -d /usr/local/nginx/ -s /sbin/nologin nginx 创建用户nginx,后面配置文件会用到
vim /usr/local/nginx/conf/nginx.conf
systemctl reload nginx
Use curl to access server2 in server1 and find that load balancing has been achieved
You can also set the access weight algorithm
Set the weight of server3 to 3:
The health check that nginx comes with:
server4:
systemctl stop httpd