Browse Source

update: docker configuration

master v1.1
Dnomd343 3 years ago
parent
commit
d172bb0452
  1. 4
      Dockerfile
  2. 12
      README.md
  3. 2
      backend/queryInfo.php
  4. 1
      conf/docker/init.sh
  5. 6
      conf/nginx/docker.conf

4
Dockerfile

@ -1,4 +1,7 @@
FROM alpine FROM alpine
LABEL version="1.1" \
maintainer="dnomd343" \
description="echo client IP details"
COPY . /var/www/echoIP COPY . /var/www/echoIP
ADD ./conf/docker/init.sh / ADD ./conf/docker/init.sh /
RUN apk --update add --no-cache nginx curl nodejs php7 php7-fpm php7-json php7-iconv php7-sqlite3 php7-openssl && \ RUN apk --update add --no-cache nginx curl nodejs php7 php7-fpm php7-json php7-iconv php7-sqlite3 php7-openssl && \
@ -6,4 +9,5 @@ RUN apk --update add --no-cache nginx curl nodejs php7 php7-fpm php7-json php7-i
cp /var/www/echoIP/conf/nginx/docker.conf /etc/nginx/conf.d && \ cp /var/www/echoIP/conf/nginx/docker.conf /etc/nginx/conf.d && \
cp /var/www/echoIP/conf/docker/init.sh / && \ cp /var/www/echoIP/conf/docker/init.sh / && \
sed -i '$i\0\t0\t*\t*\t*\t/var/www/echoIP/backend/qqwryUpdate.sh' /var/spool/cron/crontabs/root sed -i '$i\0\t0\t*\t*\t*\t/var/www/echoIP/backend/qqwryUpdate.sh' /var/spool/cron/crontabs/root
EXPOSE 1601
CMD ["sh","init.sh"] CMD ["sh","init.sh"]

12
README.md

@ -32,7 +32,7 @@ shell> curl ip.343.re/8.8.8.8
### 网页访问模式 ### 网页访问模式
你可以直接在 [ip.343.re](https://ip.343.re/) 进行查询,或者将项目部署到自己的服务器上。 你可以直接在 [https://ip.343.re](https://ip.343.re) 或 [https://ip.dnomd343.top](https://ip.dnomd343.top) 进行查询,或者将项目部署到自己的服务器上。
![echoIP-web](https://pic.dnomd343.top/images/Wg7.png) ![echoIP-web](https://pic.dnomd343.top/images/Wg7.png)
@ -40,9 +40,9 @@ shell> curl ip.343.re/8.8.8.8
> 如果想在自己域名下建立本服务,可按如下方式部署 > 如果想在自己域名下建立本服务,可按如下方式部署
### Docker方式 ### Docker方式(推荐)
echoIP支持Docker容器部署,在[Docker Hub](https://hub.docker.com/repository/docker/dnomd343/echoip)或[Github Package](https://github.com/dnomd343?tab=packages&repo_name=echoIP)有打包完成的镜像下载 echoIP支持Docker容器部署,在[Docker Hub](https://hub.docker.com/repository/docker/dnomd343/echoip)可获取已构建的镜像
确定你的服务器上有Docker环境 确定你的服务器上有Docker环境
@ -55,7 +55,7 @@ shell> docker -v
``` ```
# 映射容器服务到宿主机1601端口 # 映射容器服务到宿主机1601端口
shell> docker run -dit --name echoip -p 1601:8080 dnomd343/echoip shell> docker run -d --name echoip -p 1601:1601 dnomd343/echoip
``` ```
测试容器是否正常工作 测试容器是否正常工作
@ -211,7 +211,7 @@ shell> docker build -t echoip https://github.com/dnomd343/echoIP.git#master
启动容器 启动容器
``` ```
shell> docker run -dit --name echoip -p 1601:8080 echoip shell> docker run -d --name echoip -p 1601:1601 echoip
``` ```
进入容器调试 进入容器调试
@ -251,8 +251,10 @@ ip -> 请求指定IP的数据
``` ```
shell> curl "ip.343.re/query?justip=true" shell> curl "ip.343.re/query?justip=true"
{"ip":"116.57.98.121"} {"ip":"116.57.98.121"}
shell> curl "ip.343.re/query?justip=true&cli=true" shell> curl "ip.343.re/query?justip=true&cli=true"
116.57.98.124 116.57.98.124
shell> curl "ip.343.re/query?cli=true&ip=7.7.7.7" shell> curl "ip.343.re/query?cli=true&ip=7.7.7.7"
IP: 7.7.7.7 IP: 7.7.7.7
AS: AS8003 AS: AS8003

2
backend/queryInfo.php

@ -222,7 +222,7 @@ function routeParam() {
} else { } else {
$reply = array(); $reply = array();
$reply['status'] = 'F'; $reply['status'] = 'F';
$reply['message'] = 'Illegal IP format'; $reply['message'] = 'Illegal Request';
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
echo json_encode($reply); echo json_encode($reply);
} }

1
conf/docker/init.sh

@ -2,4 +2,3 @@
/usr/sbin/nginx /usr/sbin/nginx
/usr/sbin/crond /usr/sbin/crond
node /var/www/echoIP/backend/qqwryFormat/server.js node /var/www/echoIP/backend/qqwryFormat/server.js
/bin/sh

6
conf/nginx/docker.conf

@ -1,6 +1,6 @@
server { server {
listen 8080; listen 1601;
set $this 127.0.0.1:8080; set $this 127.0.0.1:1601;
set_real_ip_from 0.0.0.0/0; set_real_ip_from 0.0.0.0/0;
real_ip_header X-Real-IP; real_ip_header X-Real-IP;
@ -70,4 +70,4 @@ server {
fastcgi_pass 127.0.0.1:9000; fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/echoIP/backend/queryInfo.php; fastcgi_param SCRIPT_FILENAME /var/www/echoIP/backend/queryInfo.php;
} }
} }

Loading…
Cancel
Save