与源服务器集成
本页涵盖两个集成阶段:
- 直接集成 — CDN 边缘直接转发至源服务器(基准测试)
- F5 XC 插入 — 在 CDN 与源服务器之间插入 F5 XC HTTP 负载均衡器(安全演示)
从直接集成开始以建立基准,准备就绪后再插入 F5 XC。
源服务器参考
Section titled “源服务器参考”origin-server 实验室组件提供用于安全测试的存在漏洞的 Web 应用程序。
| 属性 | 值 |
|---|---|
| 文档 | f5-sales-demo.github.io/origin-server |
| 代码仓库 | github.com/f5-sales-demo/origin-server |
| 默认端口 | 80 |
| 健康检查 | GET /health |
可用应用程序
Section titled “可用应用程序”从源服务器已发布的清单中获取当前应用程序目录:
MANIFEST_URL=$(curl -sf https://api.github.com/repos/f5-sales-demo/origin-server/releases/latest \ | python3 -c "import sys,json; assets=json.load(sys.stdin).get('assets',[]); print(next((a['browser_download_url'] for a in assets if a['name']=='manifest.json'),''))")curl -sf "$MANIFEST_URL" | python3 -m json.tool如果尚无发布版本,请直接使用代码仓库源:
curl -sf https://raw.githubusercontent.com/f5-sales-demo/origin-server/main/manifest.json | python3 -m json.tool清单列出了所有应用程序路径、健康检查、容器镜像以及演示功能映射。
应用程序路径
Section titled “应用程序路径”| 路径 | 应用程序 | 演示功能 |
|---|---|---|
/ | 登录页 | — |
/health | 健康检查 | — |
/juice-shop/ | OWASP Juice Shop | WAF、Bot 防御、API 安全 |
/dvwa/ | DVWA | WAF、Bot 防御 |
/vampi/ | VAmPI | API 安全 |
/httpbin/ | httpbin | 诊断 |
/whoami/ | whoami | 报头验证 |
/csd-demo/ | CSD Demo | 客户端防御 |
阶段一:直接集成(基准)
Section titled “阶段一:直接集成(基准)”┌──────────┐ ┌──────────────────────┐ ┌─────────────────────┐│ Client │────▶│ CDN Edge (NGINX) │────▶│ Origin Server ││ │ │ 20.65.90.112 │ │ 20.12.78.159 │└──────────┘ │ 67+ CDN headers │ │ Juice Shop, DVWA, │ │ Disk cache │ │ VAmPI, httpbin, │ └──────────────────────┘ │ whoami, CSD Demo │ └─────────────────────┘配置源服务器
Section titled “配置源服务器”在 CDN 边缘的 NGINX 配置中设置源服务器 IP:
ssh azureuser@<CDN_EDGE_IP>sudo sed -i 's|proxy_pass .*;|proxy_pass http://<ORIGIN_IP>;|' /etc/nginx/conf.d/cdn-edge.confsudo rm -rf /var/cache/nginx/cdn/*sudo nginx -t && sudo systemctl reload nginx或在 Terraform 部署时通过 terraform.tfvars 进行设置:
origin_server = "http://<ORIGIN_IP>"验证所有应用程序
Section titled “验证所有应用程序”通过 CDN 测试每个源应用程序:
CDN=<CDN_EDGE_IP>
# 健康检查(CDN 本地)curl -sf "http://$CDN/health" | python3 -m json.tool
# 登录页curl -sf -o /dev/null -w "/ : HTTP %{http_code}\n" "http://$CDN/"
# Juice Shopcurl -sf -o /dev/null -w "/juice-shop/ : HTTP %{http_code}\n" "http://$CDN/juice-shop/"
# DVWA(跟随重定向至登录页)curl -sf -o /dev/null -w "/dvwa/ : HTTP %{http_code}\n" -L "http://$CDN/dvwa/"
# VAmPI APIcurl -sf "http://$CDN/vampi/users/v1" | python3 -m json.tool | head -5
# httpbin 报头(以 JSON 形式显示 CDN 报头)curl -sf "http://$CDN/httpbin/headers" | python3 -m json.tool | head -10
# whoami(显示源服务器接收到的所有报头)curl -sf "http://$CDN/whoami/"
# CSD Democurl -sf -o /dev/null -w "/csd-demo/ : HTTP %{http_code}\n" "http://$CDN/csd-demo/"所有路径应返回 HTTP 200(DVWA 先返回 302,跟随后返回 200)。
在源服务器验证 CDN 报头
Section titled “在源服务器验证 CDN 报头”/whoami/ 端点显示源服务器接收到的每个报头。通过 CDN 访问时,它将展示全部 67 个以上的厂商报头:
curl -sf "http://$CDN/whoami/"验证以下关键报头是否存在:
| 厂商 | 报头 | 预期值 |
|---|---|---|
| 标准 | X-Forwarded-For | <your_ip>, <cdn_edge_ip> |
| Akamai | True-Client-Ip | <your_ip> |
| Cloudflare | Cf-Connecting-Ip | <your_ip> |
| CloudFront | Cloudfront-Viewer-Country | US |
| Fastly | Fastly-Client-Ip | <your_ip> |
| Azure FD | X-Azure-Clientip | <your_ip> |
交叉比对日志
Section titled “交叉比对日志”比较两台服务器上的访问日志以验证流量路径:
# CDN 边缘日志 — 显示您的客户端 IP 作为来源ssh azureuser@<CDN_EDGE_IP> "sudo tail -5 /var/log/nginx/access.log"
# 源服务器日志 — 显示 CDN 边缘 IP 作为来源ssh azureuser@<ORIGIN_IP> "sudo tail -5 /var/log/nginx/access.log"源服务器日志应显示 CDN 边缘 IP 作为连接客户端,而真实客户端 IP 则通过 X-Forwarded-For 及厂商特定报头传递。
# 首次请求 — MISS(从源服务器获取)curl -s -I "http://$CDN/whoami/" | grep X-Cache-Status
# 再次请求 — HIT(从 CDN 缓存提供)curl -s -I "http://$CDN/whoami/" | grep X-Cache-Status阶段二:F5 XC 插入(安全演示)
Section titled “阶段二:F5 XC 插入(安全演示)”完成基准测试后,在 CDN 与源服务器之间插入 F5 XC HTTP 负载均衡器:
┌──────────┐ ┌────────────────┐ ┌──────────────────┐ ┌─────────────────┐│ Client │────▶│ CDN Edge │────▶│ F5 XC HTTP LB │────▶│ Origin Server ││ │ │ (NGINX) │ │ WAF + Bot + API │ │ │└──────────┘ └────────────────┘ └──────────────────┘ └─────────────────┘- 创建 F5 XC HTTP 负载均衡器,将源服务器加入其源池
- 更新 CDN 边缘,使其指向 F5 XC VIP 而非直接指向源服务器:
ssh azureuser@<CDN_EDGE_IP>sudo sed -i 's|proxy_pass .*;|proxy_pass https://<F5XC_LB_VIP>;|' /etc/nginx/conf.d/cdn-edge.confsudo rm -rf /var/cache/nginx/cdn/*sudo nginx -t && sudo systemctl reload nginx- 验证 WAF 执行效果,覆盖完整链路:
# SQL 注入经 CDN → F5 XC WAF 应予拦截curl -I "http://$CDN/dvwa/vulnerabilities/sqli/?id=%27+OR+1%3D1--"
# 正常请求应通过curl -sf -o /dev/null -w "%{http_code}" "http://$CDN/juice-shop/"- 在 F5 XC 中配置可信客户端 IP 报头,以从 CDN 报头中读取真实客户端 IP(例如,Akamai 模拟使用
True-Client-IP,Cloudflare 模拟使用CF-Connecting-IP)
| 组件 | 代码仓库 | 用途 |
|---|---|---|
| CDN 边缘(本组件) | cdn-simulator | 缓存、厂商报头 |
| 源服务器 | origin-server | 存在漏洞的 Web 应用程序 |
| F5 XC 配置 | 各类(waf、api-protection、bot-* 等) | 安全策略 |
每个组件均发布供 AI 助手读取以部署基础设施的文档。源服务器以 GitHub Release 制品的形式发布端点清单,列出所有应用程序路径和健康检查信息。