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

展示

相关推荐
轻松Ai享生活1 分钟前
一步步深入学习Linux Process Scheduling
linux
绵绵细雨中的乡音2 小时前
网络基础知识
linux·网络
Peter·Pan爱编程2 小时前
Docker在Linux中安装与使用教程
linux·docker·eureka
kunge20133 小时前
Ubuntu22.04 安装virtualbox7.1
linux·virtualbox
清溪5493 小时前
DVWA中级
linux
Sadsvit4 小时前
源码编译安装LAMP架构并部署WordPress(CentOS 7)
linux·运维·服务器·架构·centos
xiaok4 小时前
为什么 lsof 显示多个 nginx 都在 “使用 443”?
linux
苦学编程的谢4 小时前
Linux
linux·运维·服务器
G_H_S_3_5 小时前
【网络运维】Linux 文本处理利器:sed 命令
linux·运维·网络·操作文本
鹧鸪yy5 小时前
认识Node.js及其与 Nginx 前端项目区别
前端·nginx·node.js