mirror of https://github.com/dnomd343/echoIP
Dnomd343
4 years ago
3 changed files with 75 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||
FROM debian |
|||
COPY . /root |
|||
ADD ./conf/docker/init.sh / |
|||
RUN mkdir -p /var/www/echoIP \ |
|||
&& mv /root/* /var/www/echoIP/ \ |
|||
&& apt update \ |
|||
&& apt install -y nginx curl \ |
|||
&& apt install -y php7.3 php7.3-fpm php7.3-sqlite3 \ |
|||
&& apt clean \ |
|||
&& cp /var/www/echoIP/conf/nginx/docker/ip.conf /etc/nginx/conf.d \ |
|||
&& chmod +x /init.sh |
|||
CMD ["sh","init.sh"] |
@ -0,0 +1,3 @@ |
|||
service php7.3-fpm start |
|||
service nginx start |
|||
/bin/bash |
@ -0,0 +1,60 @@ |
|||
server { |
|||
listen 8080; |
|||
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)) { |
|||
proxy_pass http://127.0.0.1:8080/info/$request_ip; |
|||
} |
|||
} |
|||
|
|||
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 unix:/var/run/php/php7.3-fpm.sock; |
|||
fastcgi_param QUERY_STRING $query; |
|||
fastcgi_param SCRIPT_FILENAME /var/www/echoIP/backend/queryInfo.php; |
|||
} |
|||
} |
Loading…
Reference in new issue