配置文件
server:
port: 443
ssl:
key-store: /home/halo/.halo/www.123123123.com.pfx
key-store-password: 6ewb8b19
spring:
r2dbc:
url: r2dbc:pool:mysql://localhost:3306/halo?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
username: root
password: AwT@61598611!
sql:
init:
mode: always
platform: mysql
halo:
caches:
page:
# 是否禁用页面缓存
disabled: true
# 工作目录位置
work-dir: /root/.halo2
# 外部访问地址
external-url: http://localhost:443
# 附件映射配置,通常用于迁移场景
attachment:
resource-mappings:
- pathPattern: /upload/**
locations:
- migrate-from-1.x
启动
java -jar halo-2.15.2.jar --spring.config.additional-location=optional:file:/home/halo/.halo2/halo启动
nohup java -jar halo-2.15.2.jar --spring.config.additional-location=optional:file:/home/halo/.halo/ >log.out &
自动获取证书
1. 安装Certbot:
Certbot通常可以通过包管理器安装。以下是在基于Debian的系统(如Ubuntu)上安装Certbot的命令:
sudo apt update
sudo apt install certbot
2.确保443和80没有被使用
3. 使用Certbot获取证书:
使用Certbot的standalone模式来获取证书。以下命令会请求一个证书,并将证书文件保存到指定的目录:
sudo certbot certonly --standalone -d yourdomain.com -d www.yourdomain.com
将yourdomain.com替换为您自己的域名。
4.在使用Certbot获取证书时,默认情况下,证书会被保存在/etc/letsencrypt/live/目录下。如果您想要自定义证书的保存位置,可以使用--config-dir和--work-dir选项来指定配置目录和工作目录。以下是命令示例:
sudo certbot certonly --standalone -d yourdomain.com --config-dir /path/to/config --work-dir /path/to/work --logs-dir /path/to/logs
在这个命令中:
--config-dir /path/to/config:指定配置文件和证书的保存位置。
--work-dir /path/to/work:指定Certbot执行时的临时工作目录。
--logs-dir /path/to/logs:指定日志文件的保存位置。
5.由于生成的是pem的需要转换,以下是转换PEM文件到PKCS12格式keystore的命令:
openssl pkcs12 -export -in /home/halo/.halo/live/www.123123123.com/fullchain.pem -inkey /home/halo/.halo/live/www.12312312321312.com/privkey.pem -out /path/to/yourapp/www.123123123.com.p12 -name tomcat -CAfile /path/to/ca-bundle.pem -caname root
在这个命令中,/path/to/yourapp/www.aroundwave.com.p12是生成的PKCS12格式keystore文件的路径,tomcat是别名,/path/to/ca-…
在执行这个命令时,系统会提示输入并确认密码,这个密码就是key-store-password。
6.最后,更新application.yml文件,指向新的PKCS12 keystore