72 字
1 分钟

nginx直接返回ip

2025-12-09
## nginx配置
location / {
add_header Content-Type "text/plain; charset=utf-8";
# 直接返回客户端IP
access_log off;
# 使用 echo 模块(如果安装了)
echo $remote_addr;
}

然后浏览器或者py、go都可以直接请求返回ip 示例代码:curl ip.bgspider.com

使用cdn+nginx#

location / {
return 200 "$http_x_forwarded_for";
add_header Content-Type text/plain;
}
nginx直接返回ip
https://blog.gspider.com/posts/5c79eb75a13cf5307e043374ee8aad4c/
作者
bgspider
发布于
2025-12-09
许可协议
CC BY-NC-SA 4.0
最后更新于 2025-12-09,距今已过 1 天

部分内容可能已过时

目录