Skip to content
perfect-panelPublic

About

PPanel is a pure, professional, and perfect open-source proxy panel tool, designed to be your ideal choice for learning and practical use.

Resources

Security policy

Stars

154 stars

Watchers

2 watching

Forks

Latest commit

Β 

History

816 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PPanel Server

License Go Version Go Report Card Docker CI

PPanel is a pure, professional, and perfect open-source proxy panel tool, designed for learning and practical use.

English | δΈ­ζ–‡ | Report Bug | Request Feature

Article 1.
All human beings are born free and equal in dignity and rights.
They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.

Article 12.
No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation.
Everyone has the right to the protection of the law against such interference or attacks.

Article 19.
Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers.

Source: United Nations – Universal Declaration of Human Rights (UN.org)

πŸ“‹ Overview

PPanel Server is the backend component of the PPanel project, providing robust APIs and core functionality for managing proxy services. Built with Go, it emphasizes performance, security, and scalability.

Key Features

  • PPanel supports 12 node protocols, including Shadowsocks, VLESS and Hysteria 2. See the node API compatibility table.
  • Login history records the sign-in method, client IP, user agent, time and result for account auditing.
  • Minimalist Design: Simple yet powerful, with complete business logic.
  • User Management: Full authentication and authorization system.
  • Subscription System: Manage user subscriptions and service provisioning.
  • Payments support Stripe, Alipay F2F, EPay V1/V2, Cryptomus, GMPay and PayPal Checkout, plus the built-in wallet balance. Setup guides cover EPay, GMPay and PayPal.
  • Order Management: Track and process user orders.
  • Ticket System: Built-in customer support and issue tracking.
  • Node Management: Monitor and control server nodes.
  • API Framework: Comprehensive RESTful APIs for frontend integration.

πŸš€ Quick Start

Prerequisites

  • Building from source requires Go 1.27.4 or later.
  • Choose PostgreSQL 16+ (the configuration template uses PostgreSQL), MySQL 8.0+ or MariaDB 11.8+.
  • For caching and task queues, use Redis 6.0+ or a single Dragonfly v2.1 instance started with --cluster_mode=emulated --lock_on_hashtags. See the Redis configuration guide for ACL users and per-project key prefixes.
  • Docker: Optional, for containerized deployment
  • Git: For cloning the repository

Deploying a release binary instead of building? See the installation guide (script/install.sh, systemd unit, checksum verification) and the configuration guide.

Installation from Source

  1. Clone the repository:

    git clone https://github.com/perfect-panel/backend.git
    cd backend
  2. Install dependencies:

    go mod download
  3. Build the project (the binaries land in bin/; pick the target of the machine that will run it):

    make linux-amd64
  4. Run the server:

    ./bin/ppanel-server-linux-amd64 run --config etc/ppanel.yaml

    When the database address and connection environment variables are unset, the first start serves the setup wizard on 127.0.0.1 at the configured Port (http://127.0.0.1:8080/init by default), reachable from the same machine only. On a remote host open an SSH tunnel (ssh -L 8080:127.0.0.1:8080 user@host) or set PPANEL_DB and PPANEL_REDIS for a non-interactive installation; both are described in the installation guide.

🐳 Docker Deployment

The image runs as an unprivileged user (uid 65532), listens on port 8080, reads /app/etc/ppanel.yaml and reports its health through ppanel healthcheck (HEALTHCHECK). The first-run setup wizard listens on 127.0.0.1 inside the container and cannot be reached through a published port, so a container deployment provides the connections in one of two ways:

  • set PPANEL_DB and PPANEL_REDIS: on the first start the server completes the empty configuration file with them and a generated JWT secret, applies the migrations and creates the first administrator, whose password is printed once in docker logs; or
  • mount a pre-filled etc/ppanel.yaml (configuration guide).
Variable Format Example
PPANEL_DB MySQL DSN user:password@tcp(host:port)/dbname, or a URL: mysql://…, postgres://user:password@host:5432/dbname?sslmode=require postgres://ppanel:[email protected]:5432/ppanel?sslmode=require
PPANEL_REDIS redis://[username:password@]host[:port][/db][?prefix=project] redis://panel:[email protected]:6379/0?prefix=panel-a
  1. Build the Docker image:

    docker buildx build --platform linux/amd64 --load -t ppanel-server:latest .
  2. Run the container. The mounted configuration file must exist and be writable by uid 65532 on the first start, when the server completes it (replace the database and Redis addresses with yours):

    mkdir -p etc && touch etc/ppanel.yaml && sudo chown 65532:65532 etc/ppanel.yaml
    docker run -d --name ppanel-server -p 8080:8080 \
      -e PPANEL_DB='postgres://ppanel:[email protected]:5432/ppanel?sslmode=require' \
      -e PPANEL_REDIS='redis://:[email protected]:6379/0' \
      -v "$(pwd)/etc/ppanel.yaml:/app/etc/ppanel.yaml" \
      ppanel-server:latest
    docker logs -f ppanel-server   # prints the first administrator's password once
  3. Use Docker Compose. The repository's docker-compose.yml builds the image, publishes port 8080, mounts ./etc/ppanel.yaml and checks the container's health:

    services:
      ppanel:
        container_name: ppanel-server
        build:
          context: .
          dockerfile: Dockerfile
        ports:
          - "8080:8080"
        volumes:
          - ./etc/ppanel.yaml:/app/etc/ppanel.yaml
        # environment:
        #   PPANEL_DB: "ppanel:password@tcp(db:3306)/ppanel"
        #   PPANEL_REDIS: "redis://:password@redis:6379/0"
        healthcheck:
          test: ["CMD", "/app/ppanel", "healthcheck"]
          interval: 30s
          timeout: 5s
          retries: 3
          start_period: 30s
        stop_grace_period: 20s
        restart: always

    ./etc/ppanel.yaml must exist as a file before the first docker compose up (Docker creates a directory of that name otherwise) and be writable by uid 65532; uncomment environment or pre-fill the file, then:

    mkdir -p etc && touch etc/ppanel.yaml && sudo chown 65532:65532 etc/ppanel.yaml
    docker compose up -d

    stop_grace_period gives the graceful shutdown (HTTP first, then the scheduler, the task worker and the trace exporter, up to about 18 s) the time it needs; with plain docker run, stop with docker stop --time 20.

  4. Pull a published image from Docker Hub or GHCR. New releases publish the same manifest to both registries under these tags.

    Trigger Image tags in both registries
    Push to dev nightly, nightly-<short-sha>
    Push a beta tag such as v2.0.0-beta.1 beta, 2.0.0-beta.1
    Push a stable tag such as v2.0.0 on a commit in main latest, 2.0.0, 2.0, 2.0.0-<short-sha>

    CI runs on pushes to main. The lts tag stays pinned to 1.21.7. Stable and beta images support Linux amd64 and arm64. Nightly images support Linux amd64, with Linux arm64 binaries available in the rolling GitHub prerelease.

    docker pull ppanel/ppanel-server:latest
    docker pull ghcr.io/perfect-panel/ppanel-server:latest

The server answers GET /healthz (liveness) and GET /readyz (readiness: database and Redis reachable) for monitoring and load balancers; see the configuration guide.

πŸ“– API Documentation

API documentation is generated from Swaggo annotations on the handlers and checked against the routes actually registered by Hertz. The root ppanel.json is the complete Swagger 2.0 document:

ppanel.json

Node API

Nodes fetch the full configuration of their enabled protocols with GET /v2/server/{server_id}. The legacy configuration endpoint returns a smaller set of fields. The node software and the user’s proxy client must support the selected protocol.

Configuration endpoint Node protocols
V2 and legacy GET /v1/server/config Shadowsocks (including SS2022), VMess, VLESS, Trojan, AnyTLS, TUIC v5, Hysteria 2
V2 only ShadowsocksR (SSR), Mieru, Naive, Snell v5/v6, Nowhere v3 (NW3)

Keep /v1/server/* reachable for node operations. Under this prefix, nodes use GET for /user (user list) and /alivelist (active IP counts per subscription), and POST for /device (device admission), /push (traffic), /online (online users) and /status (node health).

Updating the API documentation

After changing a route, request DTO, or response DTO, run:

./script/generate-swagger.sh
go test ./internal/transport/http/routes -run '^TestSwagger' -count=1

GitHub Actions on main generates the full document plus the admin.json, user.json, common.json, node.json, and edge.json scopes, then syncs them to docs/public/swagger in perfect-panel/frontend. The GH_TOKEN secret needs Contents write access to that repository.

πŸ”— Related Projects

Project Description Link
PPanel Web Frontend for PPanel GitHub
ppanel-node Go node server GitHub
Terraris Rust node server GitHub
PPanel User Web User interface for PPanel Preview
PPanel Admin Web Admin interface for PPanel Preview

🌐 Official Website

Visit ppanel.dev for more details.

πŸ› Architecture

Architecture Diagram

πŸ“ Directory Structure

.
β”œβ”€β”€ cmd/              # Application entry point
β”œβ”€β”€ docs/             # Documentation
β”œβ”€β”€ etc/              # Configuration files (e.g., ppanel.yaml)
β”œβ”€β”€ internal/         # Internal modules
β”‚   β”œβ”€β”€ app/          # Assembly, bootstrap, migrations and scheduling
β”‚   β”œβ”€β”€ arch/         # Architecture boundary checks
β”‚   β”œβ”€β”€ auth/         # Shared authentication capabilities
β”‚   β”œβ”€β”€ config/       # Configuration parsing
β”‚   β”œβ”€β”€ infra/        # Mail, SMS, shared task messages and infrastructure
β”‚   β”œβ”€β”€ module/       # Business facades, contracts, entities and adapters
β”‚   β”œβ”€β”€ repository/   # Repository contracts and transaction assembly
β”‚   └── transport/    # HTTP, WebSocket and task consumers
β”œβ”€β”€ pkg/              # Utility code
β”œβ”€β”€ script/           # Installation and CI helper scripts
β”œβ”€β”€ scripts/          # Performance and maintenance scripts
β”œβ”€β”€ go.mod            # Go module definition
β”œβ”€β”€ Makefile          # Build automation
└── Dockerfile        # Docker configuration

πŸ’» Development

Build for Multiple Platforms

Use the Makefile to build for various platforms (e.g., Linux, Windows, macOS):

make all  # Builds linux-amd64, darwin-amd64, windows-amd64
make linux-arm64  # Build for specific platform

Every binary is static (CGO_ENABLED=0 -trimpath), built with the metadata from script/ldflags.sh. The release publishes ppanel-server-<os>-<arch>.tar.gz (.zip for Windows) with a SHA256SUMS file for:

  • Linux: 386, amd64, arm64 (plus the linux/amd64 and linux/arm64 container images)
  • Windows: 386, amd64, arm64
  • macOS: amd64, arm64

make additionally builds linux-amd64-v3, linux-armv5, linux-armv6, linux-armv7, windows-amd64-v3, windows-armv7 and darwin-amd64-v3.

πŸ”’ Security

Report vulnerabilities privately through GitHub Security Advisories, not in public issues. SECURITY.md lists the supported versions and what to expect.

🀝 Contributing

Contributions are welcome! Please follow the Contribution Guidelines for bug fixes, features, or documentation improvements.

✨ Special Thanks

A huge thank you to the following outstanding open-source projects that have provided invaluable support for this project's development! πŸš€

Project Description Project Description
Hertz
Hertz Stars
High-performance Go HTTP framework
Gorm
Gorm
Gorm Stars
Powerful Go ORM framework
Asynq
Asynq
Asynq Stars
Asynchronous task queue for Go
Go-Swagger
Go-Swagger
Go-Swagger Stars
Comprehensive Go Swagger toolkit

πŸŽ‰ Salute to Open Source: Thank you to the open-source community for making development simpler and more efficient! Please give these projects a ⭐ to support the open-source movement!

πŸ“„ License

This project is licensed under the GPL-3.0 License.

About

PPanel is a pure, professional, and perfect open-source proxy panel tool, designed to be your ideal choice for learning and practical use.

Resources

Security policy

Stars

154 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages