lolly/docs/config/load-balancing/round-robin.conf
xfy 6543422281 docs: 添加 Nginx 配置和 Lua 脚本示例文档
- config: 反向代理、缓存、负载均衡、安全、SSL 等配置模板
- lua: API 网关、认证、动态路由、限流、WebSocket 等脚本示例

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 17:59:22 +08:00

66 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# Nginx 负载均衡 - 轮询配置示例
# ============================================================
#
# 功能说明:
# - 默认轮询算法
# - 均匀分配请求到后端服务器
# - 连接保持优化
#
# Lolly 对应配置:
# server:
# proxy:
# - path: "/api"
# targets:
# - url: "http://backend1:8080"
# - url: "http://backend2:8080"
# - url: "http://backend3:8080"
# load_balance: "round_robin" # 默认值
# ============================================================
upstream backend {
# 轮询(默认算法,无需指定)
# Lolly 对应: load_balance: "round_robin"
server backend1:8080;
server backend2:8080;
server backend3:8080;
# 连接保持
keepalive 32;
# 保持连接超时
keepalive_timeout 60s;
# 每个连接最大请求数
keepalive_requests 100;
}
server {
listen 80;
server_name lb.example.com;
location /api {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
# 后端服务器状态参数:
#
# server backend:8080 weight=N; # 权重
# server backend:8080 max_fails=N; # 最大失败次数(默认 1
# server backend:8080 fail_timeout=T; # 失败超时(默认 10s
# server backend:8080 backup; # 备用服务器
# server backend:8080 down; # 标记为不可用
#
# 示例:
# upstream backend {
# server backend1:8080 max_fails=3 fail_timeout=30s;
# server backend2:8080 backup;
# }