Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
refactor: 重构用户模型和密码验证逻辑 feat(epay): 添加支付类型支持 docs: 添加安装和配置指南文档 fix: 修复优惠券过期检查逻辑 perf: 优化设备解绑缓存清理流程 test: 添加密码验证测试用例 chore: 更新依赖版本
6.8 KiB
6.8 KiB
PPanel Configuration Guide
This document provides a comprehensive guide to the configuration file for the PPanel application. The configuration file is in YAML format and defines settings for the server, logging, database, Redis, and admin access.
1. Configuration File Overview
- Default Path:
./etc/ppanel.yaml - Custom Path: Specify a custom path using the
--configstartup parameter. - Format: YAML, supports comments, and must be named with a
.yamlextension.
2. Configuration File Structure
Below is an example of the configuration file with default values and explanations:
# PPanel Configuration
Host: "0.0.0.0" # Server listening address
Port: 8080 # Server listening port
Debug: false # Enable debug mode (disables background logging)
JwtAuth: # JWT authentication settings
AccessSecret: "" # Access token secret (randomly generated if empty)
AccessExpire: 604800 # Access token expiration (seconds)
Logger: # Logging configuration
ServiceName: "" # Service name for log identification
Mode: "console" # Log output mode (console, file, volume)
Encoding: "json" # Log format (json, plain)
TimeFormat: "2006-01-02T15:04:05.000Z07:00" # Custom time format
Path: "logs" # Log file directory
Level: "info" # Log level (info, error, severe)
Compress: false # Enable log compression
KeepDays: 7 # Log retention period (days)
StackCooldownMillis: 100 # Stack trace cooldown (milliseconds)
MaxBackups: 3 # Maximum number of log backups
MaxSize: 50 # Maximum log file size (MB)
Rotation: "daily" # Log rotation strategy (daily, size)
MySQL: # MySQL database configuration
Addr: "" # MySQL address (required)
Username: "" # MySQL username (required)
Password: "" # MySQL password (required)
Dbname: "" # MySQL database name (required)
Config: "charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai" # MySQL connection parameters
MaxIdleConns: 10 # Maximum idle connections
MaxOpenConns: 100 # Maximum open connections
LogMode: "info" # Log level (debug, error, warn, info)
LogZap: true # Enable Zap logging for SQL
SlowThreshold: 1000 # Slow query threshold (milliseconds)
Redis: # Redis configuration
Host: "localhost:6379" # Redis address
Pass: "" # Redis password
DB: 0 # Redis database index
Administer: # Admin login configuration
Email: "admin@ppanel.dev" # Admin login email
Password: "password" # Admin login password
3. Configuration Details
3.1 Server Settings
Host: Address the server listens on.- Default:
0.0.0.0(all network interfaces).
- Default:
Port: Port the server listens on.- Default:
8080.
- Default:
Debug: Enables debug mode, disabling background logging.- Default:
false.
- Default:
3.2 JWT Authentication (JwtAuth)
AccessSecret: Secret key for access tokens.- Default: Randomly generated if not specified.
AccessExpire: Token expiration time in seconds.- Default:
604800(7 days).
- Default:
3.3 Logging (Logger)
ServiceName: Identifier for logs, used as the log filename involumemode.- Default:
"".
- Default:
Mode: Log output destination.- Options:
console(stdout/stderr),file(to a directory),volume(Docker volume). - Default:
console.
- Options:
Encoding: Log format.- Options:
json(structured JSON),plain(plain text with colors). - Default:
json.
- Options:
TimeFormat: Custom time format for logs.- Default:
2006-01-02T15:04:05.000Z07:00.
- Default:
Path: Directory for log files.- Default:
logs.
- Default:
Level: Log filtering level.- Options:
info(all logs),error(error and severe),severe(severe only). - Default:
info.
- Options:
Compress: Enable compression for log files (only infilemode).- Default:
false.
- Default:
KeepDays: Retention period for log files (in days).- Default:
7.
- Default:
StackCooldownMillis: Cooldown for stack trace logging to prevent log flooding.- Default:
100.
- Default:
MaxBackups: Maximum number of log backups (forsizerotation).- Default:
3.
- Default:
MaxSize: Maximum log file size in MB (forsizerotation).- Default:
50.
- Default:
Rotation: Log rotation strategy.- Options:
daily(rotate daily),size(rotate by size). - Default:
daily.
- Options:
3.4 MySQL Database (MySQL)
Addr: MySQL server address.- Required.
Username: MySQL username.- Required.
Password: MySQL password.- Required.
Dbname: MySQL database name.- Required.
Config: MySQL connection parameters.- Default:
charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai.
- Default:
MaxIdleConns: Maximum idle connections.- Default:
10.
- Default:
MaxOpenConns: Maximum open connections.- Default:
100.
- Default:
LogMode: SQL logging level.- Options:
debug,error,warn,info. - Default:
info.
- Options:
LogZap: Enable Zap logging for SQL queries.- Default:
true.
- Default:
SlowThreshold: Threshold for slow query logging (in milliseconds).- Default:
1000.
- Default:
3.5 Redis (Redis)
Host: Redis server address.- Default:
localhost:6379.
- Default:
Pass: Redis password.- Default:
""(no password).
- Default:
DB: Redis database index.- Default:
0.
- Default:
3.6 Admin Login (Administer)
Email: Admin login email.- Default:
admin@ppanel.dev.
- Default:
Password: Admin login password.- Default:
password.
- Default:
4. Environment Variables
The following environment variables can be used to override configuration settings:
| Environment Variable | Configuration Section | Example Value |
|---|---|---|
PPANEL_DB |
MySQL | root:password@tcp(localhost:3306)/vpnboard |
PPANEL_REDIS |
Redis | redis://localhost:6379 |
5. Best Practices
- Security: Avoid using default
Administercredentials in production. UpdateEmailandPasswordto secure values. - Logging: Use
fileorvolumemode for production to persist logs. AdjustLeveltoerrororsevereto reduce log volume. - Database: Ensure
MySQLandRediscredentials are secure and not exposed in version control. - JWT: Specify a strong
AccessSecretforJwtAuthto enhance security.
For further assistance, refer to the official PPanel documentation or contact support.