网络知识分享

Mynodequery | 探针 VPS监控 放弃Nezha哪吒 教程 麦兜

不开源;仅docker安装;ARM主...

标签:

不开源;仅docker安装;ARM主机不能当主控

#youtube视频

https://youtu.be/aKLGEyfouUM

#项目地址
https://hub.docker.com/r/jaydenlee2019/mynodequery

#更新和安装必要的组件
apt update && apt upgrade -y && apt install curl socat wget -y

#安装docker
curl -fsSL https://get.docker.com | bash -s docker
会卡一点时间的

#测试安装是否成功
docker -v
输出
Docker version 27.3.1, build ce12230

#安装Docker-compose

curl -L "https://github.com/docker/compose/releases/download/v2.29.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose

#测试是否安装成功
docker-compose version
输出
docker Compose version v2.29.6

#创建目录
mkdir -p /home/web/mynodequery /home/web/mysql /home/web/certs && touch /home/web/nginx.conf /home/web/docker-compose.yml

#docker compse配置文件
/home/web/docker-compose.yml

services:
  nginx:
    image: nginx
    container_name: nginx
    restart: always
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /home/web/nginx.conf:/etc/nginx/nginx.conf
      - /home/web/certs:/etc/nginx/certs

  mysql:
    image: mysql
    container_name: mysql # 主机名
    restart: always
    ports:
      - "3306:3306"
    volumes:
      - /home/web/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword # root密码
      MYSQL_DATABASE: mynodequery # 数据库名

  mynodequery:
    image: jaydenlee2019/mynodequery:latest
    container_name: mynodequery
    restart: always
    ports:
      - "5000:5000"
    volumes:
      - /home/web/mynodequery/appsettings.json:/app/appsettings.json
    links:
      - mysql

 

#mynodequery配置文件写入

cat > /home/web/mynodequery/appsettings.json <<EOF
{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "MySql": {
        "ConnectionString": ""
    },
    "AllowedHosts": "*",
    "Installed": "false",
    "ReadNodeIpHeaderKey": "X-Real-IP"
}
EOF

#添加软连接
ln -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh

#切换CA机构:
acme.sh –set-default-ca –server letsencrypt
acme.sh –set-default-ca –server ZeroSSL

#申请证书
acme.sh –register-account -m mailhottest@gmail.com
acme.sh –issue -d 域名 –standalone

#安装证书
acme.sh –install-cert -d 域名 –ecc \
–key-file /home/web/certs/private.key \
–fullchain-file /home/web/certs/fullchain.cer

#nginx配置
/home/web

worker_processes auto;

error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    keepalive_timeout 65;

    # HTTP 重定向到 HTTPS
    server {
        listen 80;
        server_name xxx.xxx; #修改为你的域名

        # 301 重定向 HTTP 到 HTTPS
        return 301 https://$host$request_uri;
    }

    # HTTPS 配置
    server {
        listen 443 ssl;  # 监听 HTTPS 端口
        server_name xxx.xxx; #修改为你的域名

        # SSL 证书路径
        ssl_certificate /etc/nginx/certs/fullchain.cer;  # 证书文件路径
        ssl_certificate_key /etc/nginx/certs/private.key;  # 私钥文件路径

        # SSL 协议和加密套件
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers HIGH:!aNULL:!MD5;

        # 反向代理到容器内的 5000 端口
        location / {
            proxy_pass http://172.17.0.1:5000;  # 假设容器网络地址为 172.17.0.1:5000
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
}

 

#启动docker
docker-compose -f /home/web/docker-compose.yml up -d

#容器状态
docker ps

#某程序的log,后面的数字是container id
docker logs <容器ID或名称>

#停止某个docker
docker kill <容器ID或名称>

#重启指定容器
docker restart <容器ID或名称>

#全国ICMP Ping监控节点地址
https://www.nodeseek.com/post-82748-1

 

相关导航

暂无评论

暂无评论...