ae273d5b92
Add ssl_mode configuration option to allow users to customize SSL/TLS policy for database connections instead of hardcoding sslmode=disable for PostgreSQL and having no TLS support for MySQL. Changes: - database.Config, DatabaseConfig: add SSLMode field - PostgreSQL DSN: replace hardcoded sslmode=disable with configurable value - MySQL DSN: append &tls=<SSLMode> parameter when SSLMode is set - Full config pipeline: INI/env -> DatabaseConfig -> Config -> DSN -> subprocess - New env var BH_DB_SSL_MODE and ini key [database] ssl_mode - Updated config example and documentation
40 lines
1.2 KiB
INI
40 lines
1.2 KiB
INI
[server]
|
|
# 服务监听端口
|
|
port = 8052
|
|
# 服务监听地址
|
|
host = 0.0.0.0
|
|
# URL前缀,例如 /baihu,留空则无前缀
|
|
# 配置后:前端路径为 /baihu/*,后端API路径为 /baihu/api/v1/*
|
|
url_prefix =
|
|
|
|
[database]
|
|
# 数据库类型: sqlite, mysql, postgres
|
|
type = sqlite
|
|
# 数据库连接地址 (mysql/postgres)
|
|
host = localhost
|
|
# 数据库连接端口 (mysql: 3306, postgres: 5432)
|
|
port = 3306
|
|
# 数据库用户名
|
|
user = root
|
|
# 数据库密码
|
|
password =
|
|
# 数据库名称
|
|
dbname = baihu
|
|
# 数据库文件路径 (仅 sqlite)
|
|
path = data/baihu.db
|
|
# 数据库 DSN (仅 mysql/postgres, 如果设置则优先使用。注意:需同时将 type 设置为 mysql 或 postgres)
|
|
# 例如 (MySQL): user:password@unix(/var/run/mysqld/mysqld.sock)/dbname?charset=utf8mb4&parseTime=True&loc=Local
|
|
# 例如 (Postgres): postgres://user:password@localhost:5432/dbname?sslmode=disable
|
|
dsn =
|
|
# 表前缀
|
|
table_prefix = baihu_
|
|
# SSL 模式 (仅 mysql/postgres): postgres 支持 disable/require/verify-ca/verify-full; mysql 支持 true/skip-verify
|
|
# ssl_mode = disable
|
|
|
|
[security]
|
|
# JWT 密钥。留空则在首次启动时自动生成并保存到数据库设置中。
|
|
# 如果你手动设置了此项,它将覆盖数据库中的设置。
|
|
secret =
|
|
|
|
|