nginx反向代理-负载均衡

nginx环境搭建

wget https://nginx.org/download/nginx-1.21.6.tar.gz(下载nginx安装包)

tar -xvzf nginx-1.21.6.tar.gz(解压缩)

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel(下载依赖库和包)

./configure --prefix=/soft/nginx/

make && make install(编译并安装)

sbin/nginx -s reload -c conf/nginx.conf # 修改配置后平滑重启

nginx反向代理

upstream nginx_boot{

30s内检查心跳发送两次包,未回复就代表该机器宕机,请求分发权重比为1:2

server 192.168.0.000:8080 weight=100 max_fails=2 fail_timeout=30s;

server 192.168.0.000:8090 weight=200 max_fails=2 fail_timeout=30s;

这里的IP请配置成你WEB服务所在的机器IP

}

server {

location / {

root html;

配置一下index的地址,最后加上index.ftl。

index index.html index.htm index.jsp index.ftl;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

请求交给名为nginx_boot的upstream上

proxy_pass http://nginx_boot;

}

}

相关推荐
木子.李3471 小时前
ssh连接远程服务器相关总结
运维·服务器·ssh
晚风吹人醒.2 小时前
SSH远程管理及访问控制
linux·运维·ssh·scp·xshell·访问控制·远程管理
necessary6534 小时前
使用Clion查看linux环境中的PG源码
linux·运维·服务器
江湖有缘5 小时前
Jump个人仪表盘Docker化部署教程:从0到 搭建专属导航页
运维·docker·容器
FL16238631295 小时前
win11+WSL+Ubuntu-xrdp+远程桌面闪退+黑屏闪退解决
linux·运维·ubuntu
AOwhisky6 小时前
Linux逻辑卷管理:从“固定隔间”到“弹性存储池”的智慧
linux·运维·服务器
05大叔7 小时前
大事件Day02
运维·服务器
五仁火烧7 小时前
Vue3 项目的默认端口行为
服务器·vue.js·nginx·容器·vue
C Yu小白8 小时前
Linux系统调用与文件操作详解
linux·运维·服务器
ZFB00018 小时前
【麒麟桌面系统】V10-SP1 2503 系统知识——常见用户组简介
linux·运维·kylin