使用 curl 命令伪造 X-Forwarded-For 请求头访问服务:

curl -H "X-Forwarded-For: 8.8.8.8" https://open-sys.zjlll.cn/

100.125.69.6 - - [05/Nov/2025:16:05:40 +0800] "GET / HTTP/1.1" 401 37 "-" "curl/7.29.0" "8.8.8.8, 125.124.72.244"

先检查有没有realip模块

nginx -V 2>&1 | grep realip

location = /debug {
default_type text/plain;
return 200 "remote_addr: $remote_addr\nrealip_remote_addr: $realip_remote_addr\nhttp_x_forwarded_for: $http_x_forwarded_for\n";

}

nginx.conf http { set_real_ip_from 100.125.69.0/24; real_ip_header X-Forwarded-For; real_ip_recursive on; }

for f in *.conf; do sed -i 's/proxy_set_header X-Real-IP \$remote_addr;/proxy_set_header remote_addr \$remote_addr;/g' "$f" done

0 子项 · 1 次浏览 · 2026-09-16