#!/usr/bin/env bash # 由 EdgeOne 节点 CIDR 清单生成 realip 配置,供 realip-edgeone.conf 使用。 # # EdgeOne 节点网段会变动,需从 EdgeOne 控制台或 API 导出为「每行一个 CIDR」 # 的清单后传入本脚本(不硬编码易过期的网段)。 # # 用法: sudo bash deploy/nginx/update-edgeone-ips.sh [输出文件] # 默认输出: /etc/nginx/edgeone-ips.conf set -euo pipefail SOURCE="${1:?用法: update-edgeone-ips.sh [输出文件]}" OUT="${2:-/etc/nginx/edgeone-ips.conf}" sed '/^[[:space:]]*#/d; /^[[:space:]]*$/d; s|^|set_real_ip_from |; s|$|;|' "$SOURCE" > "${OUT}.tmp" mv "${OUT}.tmp" "$OUT" echo "已写入 $OUT" if command -v nginx >/dev/null 2>&1; then nginx -t && nginx -s reload fi