nginx反向代理、负载均衡

修改nginx.conf的配置

复制代码
upstream nginx_boot{
   # 30s内检查心跳发送两次包,未回复就代表该机器宕机,请求分发权重比为1:2
   server 192.168.87.143 weight=100 max_fails=2 fail_timeout=30s; 
   server 192.168.87.1 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;
    }
}

在打开一台虚拟机(配置好nginx)和本地nginx

展示

相关推荐
追赶sun7 分钟前
Ubuntu 添加系统调用
linux·ubuntu·操作系统·系统调用
北漂老男孩15 分钟前
在 Linux 上安装 MATLAB:完整指南与疑难解决方案
linux·运维·matlab
像风一样的男人@1 小时前
Linux --systemctl损坏
linux·运维·服务器
南棱笑笑生1 小时前
20250515测试飞凌的OK3588-C的核心板在Linux R4下适配以太网RTL8211F-CG时跑iperf3的极速
linux·服务器·网络
南方以南_1 小时前
【云实验】搭建个人网盘实验
linux·运维·服务器
酷爱码1 小时前
Linux实现临时RAM登录的方法汇总
linux·前端·javascript
muxue1782 小时前
chmod 777含义:
linux
帷幄庸者2 小时前
CentOS 上配置 Docker 使用 NVIDIA GPU
linux·docker·centos
xbd_zc2 小时前
【Linux Nano Vim快捷键大全】
linux·运维·vim
shane-u3 小时前
Dockerfile实战:从零构建自定义CentOS镜像
linux·运维·centos