侧边栏壁纸
  • 累计撰写 17 篇文章
  • 累计创建 0 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Docker-Compose一键搭建Halo博客和nginx反向代理配置SSL

cosmosbreak
2022-05-08 / 0 评论 / 0 点赞 / 441 阅读 / 267 字

安装docker和docker-compose

curl -fsSL https://get.docker.com | bash -s docker

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

搭建Halo博客和nginx反代

使用Docker-Compose运行下面的yaml

#docker-compose.yaml
version: "3"

services:
  nginx:
    image: nginx:1.19.10
    restart: always
    environment:
      - TZ=Asia/Shanghai
    network_mode: host
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./logs:/var/log/nginx
      - /etc/letsencrypt:/etc/letsencrypt

  halo:
    image: halohub/halo:1.5.2
    container_name: halo
    volumes:
      - ./:/root/.halo
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    network_mode: host
    environment:
      - SERVER_PORT=8090
      - SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.h2.Driver
      - SPRING_DATASOURCE_URL=jdbc:h2:file:~/.halo/db/halo
      - SPRING_DATASOURCE_USERNAME=admin
      - SPRING_DATASOURCE_PASSWORD=o#DwN&JSa56
      - HALO_ADMIN_PATH=admin
      - HALO_CACHE=memory

certbot签发SSL证书

根据certbot官网,https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal,进行配置

apt install snapd -y
snap install core; sudo snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot

签发SSL证书并生成nginx配置

certbot --nginx

将nginx配置文件复制到nginx文件夹,取名为halo.conf

运行Halo

docker-compose up -d

certbot只签发SSL证书

certbot certonly
0

评论区