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

84 lines
2.1 KiB
Plaintext
Raw Permalink 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 HTTP/3 (QUIC) 配置示例
# ============================================================
#
# 功能说明:
# - HTTP/3 基于 QUIC 协议
# - UDP 替代 TCP减少握手延迟
# - 0-RTT 早期数据,更快连接
#
# Lolly 对应配置:
# server:
# ssl:
# cert: "/path/to/cert.pem"
# key: "/path/to/key.pem"
# http3:
# enabled: true
# listen: ":443"
# max_streams: 100
# idle_timeout: 60s
# enable_0rtt: false
# ============================================================
# nginx 需要 --with-http_v3_module 编译选项
# 或使用 nginx-quic 分支
server {
# HTTP/3 监听 (UDP)
listen 443 quic reuseport;
# HTTP/2 和 HTTP/1.1 监听 (TCP)
listen 443 ssl http2;
server_name http3.example.com;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_protocols TLSv1.3; # HTTP/3 仅支持 TLS 1.3
# HTTP/3 配置
# Lolly 对应: http3 配置块
# Alt-Svc 头: 通告 HTTP/3 支持
add_header Alt-Svc 'h3=":443"; ma=86400';
root /var/www/html;
location / {
try_files $uri $uri/ =404;
}
}
# HTTP/3 说明:
#
# 1. QUIC 协议:
# - 基于 UDP避免 TCP 队头阻塞
# - 内置 TLS 1.30-RTT 连接恢复
# - 连接迁移:网络切换时保持连接
#
# 2. HTTP/3 vs HTTP/2:
# - HTTP/2: TCP + TLS需要两次握手
# - HTTP/3: QUIC单次握手
# - HTTP/3 避免队头阻塞问题
#
# 3. 0-RTT 特性:
# - 客户端缓存 Session Ticket
# - 首次连接后,后续连接可立即发送数据
# - 安全风险:可能被重放攻击
# - Lolly 对应: http3.enable_0rtt: false默认禁用
#
# 4. Alt-Svc 通告:
# - 服务端通过 Alt-Svc 头告知 HTTP/3 支持
# - 格式: h3=":443"; ma=86400
# - 客户端收到后尝试 HTTP/3 连接
#
# 5. Lolly HTTP/3 实现:
# - 基于 quic-go 库
# - 支持 0-RTT可选启用
# - 与 HTTP/1.1/HTTP/2 共存
# - UDP 和 TCP 同时监听
#
# 6. 网络要求:
# - UDP 443 端口开放
# - 部分网络可能限制 UDP
# - 支持 fallback 到 HTTP/2