显示客户端IP的详细信息
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

root /var/www/echoIP;
resolver 8.8.8.8;
location = / {
if ($http_user_agent ~* (curl|wget)) {
return 200 $remote_addr\n;
}
if ($scheme = http) {
return 301 https://$server_name;
}
index index.html;
}
location = /ua {
if ($http_user_agent ~* (curl|wget)) {
return 200 $http_user_agent\n;
}
default_type application/json;
return 200 $http_user_agent;
}
location = /ip {
if ($http_user_agent ~* (curl|wget)) {
return 200 $remote_addr\n;
}
if ($scheme = http) {
return 301 https://$server_name/ip;
}
return 200 $remote_addr;
}
location ~* ^/([^/]+?)$ {
set $request_ip $1;
if ($http_user_agent ~* (curl|wget)) {
proxy_pass https://ip.343.re/info/$request_ip; # 改成自己的域名
break;
}
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
}
location ^~ /info {
set $is_cli 0;
set $is_https 0;
set $is_legal 0;
if ($uri ~* ^/info/?$) {
set $is_legal 1;
set $query ip=$remote_addr;
}
if ($uri ~* ^/info/([^/]+?)$) {
set $is_legal 1;
set $query ip=$1;
}
if ($is_legal = 0) {
return 404;
}
if ($scheme = https) {
set $is_https 1;
}
if ($http_user_agent ~* (curl|wget)) {
set $is_cli 1;
set $query $query&cli=true;
}
set $flag_https_cli $is_https$is_cli;
if ($flag_https_cli = 00) {
return 301 https://$server_name$request_uri;
}
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000; # php-fpm接口
fastcgi_param QUERY_STRING $query;
fastcgi_param SCRIPT_FILENAME /var/www/echoIP/backend/queryInfo.php;
}