安装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
评论区