Nginx的获取IP的网页
套了CF的用法($http_cf_connecting_ip)
location /ip {
add_header Content-Type text/plain;
return 200 $http_cf_connecting_ip;
}
套了CDN(包括CF)/有反代($http_x_forwarded_for)
location /ip {
add_header Content-Type text/plain;
return 200 $http_x_forwarded_for;
}
没有使用CDN直接用$remote_addr
location /ip {
add_header Content-Type text/plain;
return 200 $remote_addr;
}
综合使用
location /ip {
add_header Content-Type text/plain;
if ($http_cf_connecting_ip != "") { return 200 $http_cf_connecting_ip; }
if ($http_x_forwarded_for != "") { return 200 $http_x_forwarded_for; }
if ($remote_addr != "") { return 200 $remote_addr; }
}
转自:https://hostloc.com/thread-1164027-1-1.html
感谢,【嗷嗷】大佬的教程