DailyHot一个聚合每日热门数据的API接口——筑梦之路

官方示例网站

今日热榜 - 汇聚全网热点,热门尽览无余

开源地址:https://github.com/imsyy/DailyHot.git

# 前端镜像Dockerfile文件

FROM node:18-alpine as build-deps

WORKDIR /app
COPY . ./
RUN npm i -g pnpm
RUN pnpm install
RUN pnpm build

FROM nginx:1.12-alpine    
   

# 环境变量    
ENV VITE_GLOBAL_API "https://api-hot.efefee.cn"  
ENV VITE_ICP "豫ICP备2022018134号-1" 

# 拷贝静态文件    
COPY --from=build-deps /app/dist /usr/share/nginx/html

COPY replace_apiurl.sh ./replace_apiurl.sh
RUN chmod +x replace_apiurl.sh 

EXPOSE 80    
CMD ["sh", "replace_apiurl.sh"]

# 脚本replace_apiurl.sh

#!/bin/bash  
  
find '/usr/share/nginx/html' -name '*.js' -exec sed -i -e 's,vitegloalapi,'"$VITE_GLOBAL_API"',g' {} \;  
  
find '/usr/share/nginx/html' -name '*.js' -exec sed -i -e 's,viteicp,'"$VITE_ICP"',g' {} \;  
  
nginx -g "daemon off;"

# 修改.env文件

# 全局 API 地址
# VITE_GLOBAL_API="http://localhost:6688"
VITE_GLOBAL_API="https://api-hot.imsyy.top"

# ICP 备案号
VITE_ICP = "豫ICP备2022018134号-1"

# 全局目录
VITE_DIR = "/"

# 构建前端镜像

docker  build  -t   [镜像地址]

一键部署

services:
  dailyhotapi:
    ##image: dailyhot-api
    image: docker.cnb.cool/srebro/pidin/dailyhotapi:latest  ##CNB镜像加速地址
    container_name: dailyhotapi
    volumes:
      - "./logs:/app/logs"
    ports:
      - 6688:6688
    restart: always
  dailyhotui:
    image: docker.cnb.cool/srebro/pidin/dailyhotui:latest ##CNB镜像加速地址
    container_name: dailyhotui
    #environment:
    #  - VITE_GLOBAL_API=http://192.168.100.100:6688
    ports:
      - 8848:8848
    restart: always

nginx反向代理

#dailyhotui
  server {
        listen       443 ssl;
        server_name  xxxxx;
        error_page  404              /404/404.html;
        charset utf-8;

        ssl_certificate /home/application/nginx/cert/xxxx.pem; 
        ssl_certificate_key /home/application/nginx/cert/xxxx.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

 location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header x-wiz-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://localhost:8848;
        }


 location /api/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header x-wiz-real-ip $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        ##代理到DailyHotapi接口上
        proxy_pass http://localhost:6688/;

 }
}

搜集来自DailyHot | 一个聚合每日热门数据的 API 接口

cat docker-compose.yml
services:
  dailyhot-api:
    image: imsyy/dailyhot-api
    container_name: dailyhot-api
    restart: unless-stopped
    ports:
      - 6688:6688
    
  dailyhot-web:
    image: wbsu2003/dailyhot
    container_name: dailyhot-web
    restart: unless-stopped
    ports:
      - 6689:80
    environment:
      - VITE_GLOBAL_API=http://192.168.100.78:6688
      - VITE_ICP=

# 访问地址

192.168.100.78:6689

参考资料:

能聚合各站热点的DailyHot-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值