init
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
### 配置文件说明
|
||||
|
||||
#### 1. 配置文件路径
|
||||
|
||||
配置文件默认路径为:`./etc/ppanel.yaml`,可通过启动参数 `--config` 指定配置文件路径。
|
||||
|
||||
#### 2. 配置文件格式
|
||||
- 配置文件为yaml格式,支持注释,命名为xxx.yaml。
|
||||
|
||||
```yaml
|
||||
# 配置文件示例
|
||||
Host: # 服务监听地址,默认: 0.0.0.0
|
||||
Port: # 服务监听端口,默认: 8080
|
||||
Debug: # 是否开启调试模式,开启后无法使用后台日志功能, 默认: false
|
||||
JwtAuth: # JWT认证配置
|
||||
AccessSecret: # 访问令牌密钥, 默认: 随机生成
|
||||
AccessExpire: # 访问令牌过期时间,单位秒, 默认: 604800
|
||||
Logger: # 日志配置
|
||||
FilePath: # 日志文件路径, 默认: ./ppanel.log
|
||||
MaxSize: # 日志文件最大大小,单位MB, 默认: 50
|
||||
MaxBackup: # 日志文件最大备份数, 默认: 3
|
||||
MaxAge: # 日志文件最大保存时间,单位天, 默认: 30
|
||||
Compress: # 是否压缩日志文件, 默认: true
|
||||
Level: # 日志级别, 默认: info, 可选: debug, info, warn, error, panic, panic, fatal
|
||||
MySQL:
|
||||
Addr: # MySQL地址, 必填
|
||||
Username: # MySQL用户名, 必填
|
||||
Password: # MySQL密码, 必填
|
||||
Dbname: # MySQL数据库名, 必填
|
||||
Config: # Mysql配置默认值 charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: # 最大空闲连接数, 默认: 10
|
||||
MaxOpenConns: # 最大打开连接数, 默认: 100
|
||||
LogMode: # 日志级别, 默认: info, 可选: debug, error, warn, info
|
||||
LogZap: # 是否使用zap日志记录sql, 默认: true
|
||||
SlowThreshold: # 慢查询阈值,单位毫秒, 默认: 1000
|
||||
Redis:
|
||||
Host: # Redis地址, 默认:localhost:6379
|
||||
Pass: # Redis密码, 默认: ""
|
||||
DB: # Redis数据库, 默认: 0
|
||||
|
||||
Administer:
|
||||
Email: # 后台登录邮箱, 默认: admin@ppanel.dev
|
||||
Password: # 后台登录密码, 默认: password
|
||||
|
||||
```
|
||||
|
||||
#### 3. 配置文件说明
|
||||
|
||||
- `Host`: 服务监听地址,默认: **0.0.0.0**
|
||||
- `Port`: 服务监听端口,默认: **8080**
|
||||
- `Debug`: 是否开启调试模式,开启后无法使用后台日志功能, 默认: **false**
|
||||
- `JwtAuth`: JWT认证配置
|
||||
- `AccessSecret`: 访问令牌密钥, 默认: **随机生成**
|
||||
- `AccessExpire`: 访问令牌过期时间,单位秒, 默认: **604800**
|
||||
- `Logger`: 日志配置
|
||||
- `FilePath`: 日志文件路径, 默认: **./ppanel.log**
|
||||
- `MaxSize`: 日志文件最大大小,单位MB, 默认: **50**
|
||||
- `MaxBackup`: 日志文件最大备份数, 默认: **3**
|
||||
- `MaxAge`: 日志文件最大保存时间,单位天, 默认: **30**
|
||||
- `Compress`: 是否压缩日志文件, 默认: **true**
|
||||
- `Level`: 日志级别, 默认: **info**, 可选: **debug, info, warn, error, panic, panic, fatal**
|
||||
- `MySQL`: MySQL配置
|
||||
- `Addr`: MySQL地址, 必填
|
||||
- `Username`: MySQL用户名, 必填
|
||||
- `Password`: MySQL密码, 必填
|
||||
- `Dbname`: MySQL数据库名, 必填
|
||||
- `Config`: Mysql配置默认值 charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
- `MaxIdleConns`: 最大空闲连接数, 默认: **10**
|
||||
- `MaxOpenConns`: 最大打开连接数, 默认: **100**
|
||||
- `LogMode`: 日志级别, 默认: **info**, 可选: **debug, error, warn, info**
|
||||
- `LogZap`: 是否使用zap日志记录sql, 默认: **true**
|
||||
- `SlowThreshold`: 慢查询阈值,单位毫秒, 默认: **1000**
|
||||
- `Redis`: Redis配置
|
||||
- `Host`: Redis地址, 默认: **localhost:6379**
|
||||
- `Pass`: Redis密码, 默认: **""**
|
||||
- `DB`: Redis数据库, 默认: **0**
|
||||
- `Administer`: 后台登录配置
|
||||
- `Email`: 后台登录邮箱, 默认: **admin@ppanel.dev**
|
||||
- `Password`: 后台登录密码, 默认: **password**
|
||||
|
||||
#### 4. 环境变量
|
||||
|
||||
支持的环境变量如下:
|
||||
|
||||
| 环境变量 | 配置项 | 示例 |
|
||||
|--------------|---------|:-------------------------------------------|
|
||||
| PPANEL_DB | MySQL配置 | root:password@tcp(localhost:3306)/vpnboard |
|
||||
| PPANEL_REDIS | Redis配置 | redis://localhost:6379" |
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
### Configuration File Instructions
|
||||
#### Configuration File Path
|
||||
|
||||
The default configuration file path is ./etc/ppanel.yaml. You can specify a custom path using the --config startup parameter.
|
||||
|
||||
#### Configuration File Format
|
||||
|
||||
The configuration file uses the YAML format, supports comments, and should be named xxx.yaml.
|
||||
|
||||
```yaml
|
||||
# Sample Configuration File
|
||||
Host: # Service listening address, default: 0.0.0.0
|
||||
Port: # Service listening port, default: 8080
|
||||
Debug: # Enable debug mode; disables backend logging when enabled, default: false
|
||||
JwtAuth: # JWT authentication settings
|
||||
AccessSecret: # Access token secret, default: randomly generated
|
||||
AccessExpire: # Access token expiration time in seconds, default: 604800
|
||||
Logger: # Logging configuration
|
||||
FilePath: # Log file path, default: ./ppanel.log
|
||||
MaxSize: # Maximum log file size in MB, default: 50
|
||||
MaxBackup: # Maximum number of log file backups, default: 3
|
||||
MaxAge: # Maximum log file retention time in days, default: 30
|
||||
Compress: # Whether to compress log files, default: true
|
||||
Level: # Logging level, default: info; options: debug, info, warn, error, panic, fatal
|
||||
MySQL:
|
||||
Addr: # MySQL address, required
|
||||
Username: # MySQL username, required
|
||||
Password: # MySQL password, required
|
||||
Dbname: # MySQL database name, required
|
||||
Config: # MySQL configuration, default: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
MaxIdleConns: # Maximum idle connections, default: 10
|
||||
MaxOpenConns: # Maximum open connections, default: 100
|
||||
LogMode: # Log level, default: info; options: debug, error, warn, info
|
||||
LogZap: # Whether to use zap for SQL logging, default: true
|
||||
SlowThreshold: # Slow query threshold in milliseconds, default: 1000
|
||||
Redis:
|
||||
Host: # Redis address, default: localhost:6379
|
||||
Pass: # Redis password, default: ""
|
||||
DB: # Redis database, default: 0
|
||||
|
||||
Administer:
|
||||
Email: # Admin login email, default: admin@ppanel.dev
|
||||
Password: # Admin login password, default: password
|
||||
```
|
||||
|
||||
#### 3.Configuration Descriptions
|
||||
|
||||
- Host: Service listening address, default: 0.0.0.0
|
||||
|
||||
- Port: Service listening port, default: 8080
|
||||
- Debug: Enable debug mode; disables backend logging when enabled, default: false
|
||||
|
||||
- JwtAuth: JWT authentication settings
|
||||
|
||||
- AccessSecret: Access token secret, default: randomly generated
|
||||
|
||||
- AccessExpire: Access token expiration time in seconds, default: 604800
|
||||
|
||||
- Logger: Logging configuration
|
||||
|
||||
- FilePath: Log file path, default: ./ppanel.log
|
||||
|
||||
- MaxSize: Maximum log file size in MB, default: 50
|
||||
|
||||
- MaxBackup: Maximum number of log file backups, default: 3
|
||||
|
||||
- MaxAge: Maximum log file retention time in days, default: 30
|
||||
|
||||
- Compress: Whether to compress log files, default: true
|
||||
|
||||
- Level: Logging level, default: info; options: debug, info, warn, error, panic, fatal
|
||||
|
||||
- MySQL: MySQL configuration
|
||||
|
||||
- Addr: MySQL address, required
|
||||
|
||||
- Username: MySQL username, required
|
||||
|
||||
- Password: MySQL password, required
|
||||
|
||||
- Dbname: MySQL database name, required
|
||||
|
||||
- Config: MySQL configuration, default: charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai
|
||||
|
||||
- MaxIdleConns: Maximum idle connections, default: 10
|
||||
|
||||
- MaxOpenConns: Maximum open connections, default: 100
|
||||
|
||||
- LogMode: Log level, default: info; options: debug, error, warn, info
|
||||
|
||||
- LogZap: Whether to use zap for SQL logging, default: true
|
||||
|
||||
- SlowThreshold: Slow query threshold in milliseconds, default: 1000
|
||||
|
||||
- Redis: Redis configuration
|
||||
|
||||
- Host: Redis address, default: localhost:6379
|
||||
|
||||
- Pass: Redis password, default: ""
|
||||
|
||||
- DB: Redis database, default: 0
|
||||
|
||||
- Administer: Admin login configuration
|
||||
|
||||
- Email: Admin login email, default: admin@ppanel.dev
|
||||
|
||||
- Password: Admin login password, default: password
|
||||
|
||||
#### 4. Environment Variables
|
||||
|
||||
Supported environment variables are as follows:
|
||||
|
||||
| Environment Variable | Configuration | Example |
|
||||
|-----------------------|---------------|:-------------------------------------------|
|
||||
| PPANEL_DB | MySQL config | root:password@tcp(localhost:3306)/vpnboard |
|
||||
| PPANEL_REDIS | Redis config | redis://localhost:6379" |
|
||||
@@ -0,0 +1,133 @@
|
||||
### 安装说明
|
||||
#### 前置系统要求
|
||||
- Mysql 5.7+ (推荐使用8.0)
|
||||
- Redis 6.0+ (推荐使用7.0)
|
||||
|
||||
#### 二进制安装
|
||||
1.确定系统架构,并下载对应的二进制文件
|
||||
|
||||
下载地址:`https://github.com/perfect-panel/ppanel/releases`
|
||||
|
||||
示例说明:系统:Linux amd64,用户:root,当前目录:/root
|
||||
|
||||
- 下载二进制文件
|
||||
|
||||
```shell
|
||||
$ wget https://github.com/perfect-panel/ppanel/releases/download/v0.1.0/ppanel-server-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
- 解压二进制文件
|
||||
|
||||
```shell
|
||||
$ tar -zxvf ppanel-server-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
- 进入解压后的目录
|
||||
|
||||
```shell
|
||||
$ cd ppanel-server-linux-amd64
|
||||
```
|
||||
|
||||
- 赋予二进制文件执行权限
|
||||
|
||||
```shell
|
||||
$ chmod +x ppanel-server
|
||||
```
|
||||
|
||||
- 创建 systemd 服务文件
|
||||
|
||||
```shell
|
||||
$ cat > /etc/systemd/system/ppanel.service <<EOF
|
||||
[Unit]
|
||||
Description=PPANEL Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/root/ppanel-server-linux-amd64/ppanel-server
|
||||
Restart=always
|
||||
User=root
|
||||
WorkingDirectory=/root/ppanel-server-linux-amd64
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
```
|
||||
|
||||
- 重新加载 systemd 服务
|
||||
|
||||
```shell
|
||||
$ systemctl daemon-reload
|
||||
```
|
||||
- 启动服务
|
||||
|
||||
```shell
|
||||
$ systemctl start ppanel
|
||||
```
|
||||
##### 其他说明
|
||||
1. 安装路径:二进制文件将解压到 /root/ppanel-server-linux-amd64 目录下
|
||||
2. systemd 服务:
|
||||
- 服务名称:ppanel
|
||||
- 服务配置文件:/etc/systemd/system/ppanel.service
|
||||
- 服务启动命令:systemctl start ppanel
|
||||
- 服务停止命令:systemctl stop ppanel
|
||||
- 服务重启命令:systemctl restart ppanel
|
||||
- 服务状态命令:systemctl status ppanel
|
||||
- 服务开机自启:systemctl enable ppanel
|
||||
3. 设置开机自启可通过以下命令开机自启
|
||||
```shell
|
||||
$ systemctl enable ppanel
|
||||
```
|
||||
4. 服务日志:服务日志默认输出到 /root/ppanel-server-linux-amd64/ppanel.log 文件中
|
||||
5. 可通过 `journalctl -u ppanel -f` 查看服务日志
|
||||
6. 当配置文件为空或者不存在的情况下,服务会使用默认配置启动,配置文件路径为:`./etc/ppanel.yaml`,
|
||||
请通过`http://服务器地址:8080/init` 初始化系统配置
|
||||
|
||||
#### NGINX 反向代理配置
|
||||
|
||||
以下是反向代理配置示例,将 `ppanel` 服务代理到 `api.ppanel.dev` 域名下
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name ppanel.dev;
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
add_header X-Cache $upstream_cache_status;
|
||||
|
||||
#Set Nginx Cache
|
||||
|
||||
set $static_filezbsQiET1 0;
|
||||
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
|
||||
{
|
||||
set $static_filezbsQiET1 1;
|
||||
expires 1m;
|
||||
}
|
||||
if ( $static_filezbsQiET1 = 0 )
|
||||
{
|
||||
add_header Cache-Control no-cache;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
如果使用cloudflare代理服务,需要获取到用户真实访问IP。请在Nginx配置文件中Http段落中加入:
|
||||
|
||||
- 需要依赖:**ngx_http_realip_module**模块, 使用nginx -V命令查看nginx是否已经编译该模块,没有的话需要自己编译。
|
||||
|
||||
|
||||
```nginx
|
||||
# cloudflare Start
|
||||
set_real_ip_from 0.0.0.0/0;
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
# cloudflare END
|
||||
```
|
||||
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
### Installation Instructions
|
||||
|
||||
#### Prerequisites
|
||||
- MySQL 5.7+ (recommended: 8.0)
|
||||
- Redis 6.0+ (recommended: 7.0)
|
||||
|
||||
#### Binary Installation
|
||||
|
||||
1. Determine your system architecture and download the corresponding binary file.
|
||||
|
||||
Download URL: `https://github.com/perfect-panel/ppanel/releases`
|
||||
|
||||
Example setup: OS: Linux amd64, User: root, Current directory: `/root`
|
||||
|
||||
- Download the binary file:
|
||||
|
||||
```shell
|
||||
$ wget https://github.com/perfect-panel/ppanel/releases/download/v0.1.0/ppanel-server-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
- Extract the binary file:
|
||||
|
||||
```shell
|
||||
$ tar -zxvf ppanel-server-linux-amd64.tar.gz
|
||||
```
|
||||
|
||||
- Navigate to the extracted directory:
|
||||
|
||||
```shell
|
||||
$ cd ppanel-server-linux-amd64
|
||||
```
|
||||
|
||||
- Grant execution permissions to the binary:
|
||||
|
||||
```shell
|
||||
$ chmod +x ppanel
|
||||
```
|
||||
|
||||
- Create a systemd service file:
|
||||
|
||||
```shell
|
||||
$ cat > /etc/systemd/system/ppanel.service <<EOF
|
||||
[Unit]
|
||||
Description=PPANEL Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/root/ppanel-server-linux-amd64/ppanel
|
||||
Restart=always
|
||||
User=root
|
||||
WorkingDirectory=/root/ppanel-server-linux-amd64
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
```
|
||||
|
||||
- Reload the systemd service configuration:
|
||||
|
||||
```shell
|
||||
$ systemctl daemon-reload
|
||||
```
|
||||
- Start the service:
|
||||
|
||||
```shell
|
||||
$ systemctl start ppanel
|
||||
```
|
||||
|
||||
#### Additional Notes
|
||||
|
||||
1. Installation Path: The binary files will be extracted to /root/ppanel-server-linux-amd64.
|
||||
|
||||
2. systemd Service:
|
||||
- Service Name: ppanel
|
||||
|
||||
- Service Configuration File: /etc/systemd/system/ppanel.service
|
||||
|
||||
- Service Commands:
|
||||
|
||||
- Start: systemctl start ppanel
|
||||
|
||||
- Stop: systemctl stop ppanel
|
||||
|
||||
- Restart: systemctl restart ppanel
|
||||
|
||||
- Status: systemctl status ppanel
|
||||
|
||||
- Enable on Boot: systemctl enable ppanel
|
||||
|
||||
3. Enable Auto-start: Use the following command to enable the service on boot:
|
||||
```shell
|
||||
$ systemctl enable ppanel
|
||||
```
|
||||
4. Service Logs: By default, logs are output to `/root/ppanel-server-linux-amd64/ppanel.log`.
|
||||
|
||||
5. You can view service logs using: `journalctl -u ppanel -f`
|
||||
6. If the configuration file is missing or empty, the service will start with default settings. The configuration file path is `./etc/ppanel.yaml`. Access `http://<server_address>:8080/init` to **initialize the system configuration**.
|
||||
|
||||
#### NGINX Reverse Proxy Configuration
|
||||
|
||||
Below is an example configuration to proxy the ppanel service to the domain api.ppanel.dev:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name ppanel.dev;
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
add_header X-Cache $upstream_cache_status;
|
||||
|
||||
# Set Nginx Cache
|
||||
set $static_file_cache 0;
|
||||
if ($uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$") {
|
||||
set $static_file_cache 1;
|
||||
expires 1m;
|
||||
}
|
||||
if ($static_file_cache = 0) {
|
||||
add_header Cache-Control no-cache;
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If using Cloudflare as a proxy service, you need to retrieve the user's real IP address. Add the following to the http section of the NGINX configuration file:
|
||||
|
||||
- Dependency: `ngx_http_realip_module`. Check if your NGINX build includes this module by running `nginx -V`. If not, you will need to recompile NGINX with this module.
|
||||
|
||||
```nginx
|
||||
# Cloudflare Start
|
||||
set_real_ip_from 0.0.0.0/0;
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
# Cloudflare End
|
||||
```
|
||||
Reference in New Issue
Block a user