🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 实例 配置上游服务器: ``` server { listen 8081; location / { return 200 '应用服务器1'; } } server { listen 8082; location / { return 200 '应用服务器2'; } } server { listen 8083; location / { return 200 '应用服务器3'; } } ``` 代理服务器配置: 默认的nginx代理服务器是使用轮询算法的; ``` upstream back_end{ server 192.168.33.10:8081 weight=3; //权重最高 server 192.168.33.10:8082; server 192.168.33.10:8083; } server { listen 80; server_name website.com; charset utf-8; root html; location /balance { proxy_pass http://back_end; } ``` 结果: ``` ➜ nginx curl website.com/balance 应用服务器2 ➜ nginx curl website.com/balance 应用服务器1 ➜ nginx curl website.com/balance 应用服务器3 ➜ nginx curl website.com/balance 应用服务器1 ➜ nginx curl website.com/balance 应用服务器1 ➜ nginx curl website.com/balance 应用服务器2 ➜ nginx curl website.com/balance 应用服务器1 ➜ nginx curl website.com/balance 应用服务器3 ➜ nginx curl website.com/balance 应用服务器1 ```