mirror of https://github.com/dnomd343/echoIP
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.
85 lines
2.2 KiB
85 lines
2.2 KiB
4 years ago
|
server {
|
||
|
listen 80;
|
||
4 years ago
|
listen [::]:80;
|
||
4 years ago
|
server_name ip.343.re; # 改为自己的域名
|
||
|
location / {
|
||
|
if ($http_user_agent !~* (curl|wget)) {
|
||
|
return 301 https://$server_name$request_uri;
|
||
|
}
|
||
|
proxy_set_header X-Real-IP $remote_addr;
|
||
4 years ago
|
proxy_pass http://127.0.0.1:1601;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
|
server {
|
||
|
listen 443 ssl http2;
|
||
4 years ago
|
listen [::]:443 ssl http2;
|
||
4 years ago
|
server_name ip.343.re; # 改为自己的域名
|
||
|
ssl_certificate /etc/ssl/certs/343.re/fullchain.pem; # 改为自己的证书
|
||
|
ssl_certificate_key /etc/ssl/certs/343.re/privkey.pem;
|
||
|
location / {
|
||
|
proxy_set_header X-Real-IP $remote_addr;
|
||
4 years ago
|
proxy_pass http://127.0.0.1:1601;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
|
server {
|
||
4 years ago
|
listen 1601;
|
||
4 years ago
|
root /var/www/echoIP;
|
||
|
|
||
|
set_real_ip_from 0.0.0.0/0;
|
||
|
real_ip_header X-Real-IP;
|
||
|
|
||
|
location = / {
|
||
|
if ($http_user_agent ~* (curl|wget)) {
|
||
|
return 200 $remote_addr\n;
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
return 200 $remote_addr;
|
||
|
}
|
||
|
|
||
|
location ~* ^/([^/]+?)$ {
|
||
|
set $request_ip $1;
|
||
|
if ($http_user_agent ~* (curl|wget)) {
|
||
4 years ago
|
proxy_pass http://127.0.0.1:1601/info/$request_ip;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
|
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 ($http_user_agent ~* (curl|wget)) {
|
||
|
set $query $query&cli=true;
|
||
|
}
|
||
|
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;
|
||
|
}
|
||
|
}
|