Nginx负载均衡

以宝塔举例:

点击网站->配置文件:

upstream photo.zyxweb.cn{
    server 127.0.0.1:9000 weight=3;  // 本地既是负载均衡器也是服务器 权重为3,所有权重是6也就是六次有三次连接到这个服务器
    server america.zyxweb.cn weight=2;   
    server wlcb.zyxweb.cn:29761 weight=1;
}



server
{
    listen 80;
    server_name photo.zyxweb.cn;
    index index.php index.html index.htm default.php default.htm default.html;
    root /www/wwwroot/photo.zyxweb.cn;
    location / {   // 这段是要加的,其他不用动
      
      proxy_pass http://$host;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

......

}

 

上一篇 使用Psexec命令行连接另一台计算机
下一篇 Python-封禁RDP攻击IP
ZYX

ZYX管理员

无论你遇见谁他都是你生命中该出现的 绝非偶然

本月创作热力图

2026年3月
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
加载中...
文章列表
1 Linux修改SSH端口号
Linux修改SSH端口号
2
为网站添加鼠标特效,粒子特效,下方计时
为网站添加鼠标特效,粒子特效,下方计时
3
Linux-网络配置
Linux-网络配置
4
虚拟化知识点杂记
虚拟化知识点杂记
5
宝塔反向代理api.openai.com
宝塔反向代理api.openai.com