QianheYu / headscale-panel

A management program that works with headscale
MIT License
32 stars 6 forks source link

headscale-panel

This project is developed based on the go-web-mini project, using a management system scaffold built with Go + Vue. It follows a front-end and back-end separation approach, only including the necessary parts for project development. It incorporates role-based access control (RBAC), is well-structured with reasonable packages, and is concise and easy to expand. The backend in Go includes the use of gin, gorm, jwt, and casbin, while the frontend in Vue is based on vue-element-admin: https://github.com/QianheYu/headscale-panel-ui.git

Features

Middleware

About Me

This is my first official open source project, and I have little experience with it, so if you have good advice or techniques, I look forward to talking to you, and you can start by submitting an issue. If there is an architecture that doesn't fit or changes are significant, I will refactor in due course.

Installation Instructions

Database Installation

You can install the database using either direct deployment or Docker. Here, we only provide instructions for Docker installation. If you have already installed the PostgreSQL database, you can skip this step.

Copy the deploy/postgres/docker-compose.yml file to the location where you want to store the database data files. Modify the file according to the instructions provided, and then execute the following command:

docker-compose up -d

Prepare Configuration File

Modify the configuration file based on the documentation example. You must copy the rbac_model.conf file and a pair of keys like headscale-panel-pub.pem headscale-panel-priv.pem to the same path as config.yaml You can also generate your own key pairs to instead it. But you mustn't forget that you also need to change the contents of the credentials in the login and user pages in the front-end, they are in the headscale-panel-ui project in /src/views/login/index.vue and /src/views/system/user/index.vue

Installation of headscale-panel

You can choose one of the following two deployment methods:

Docker Deployment (Recommended)

Pull the Docker image:

docker pull yqhdocker/headscale-panel:latest

Initialize the database:

If you are starting up for the first time, you will need to set init-data: true in the system in the configuration file to initialise the database and make sure to change init-data to false after initialisation

Note: If you have already initialized the database with headscale before installing headscale-panel, please use the script provided in the project to modify the database. Instructions

Then you need to run

docker run -d --net=host -v /your/headscale-panel/config/path:/etc/headscale-panel -v /your/headscale/config/path:/etc/headscale --name=headscale-panel yqhdocker/headscale-panel:latest

Direct Deployment

Download the executable file from the Releases section and place it in /usr/local/bin. Put the configuration file in the /etc/headscal-panel directory or use the -c parameter during runtime to specify the configuration file.

Initialize the database:

If you are starting up for the first time, you will need to set init-data: true in the system in the configuration file to initialise the database and make sure to change init-data to false after initialisation

Note: If you have already initialized the database with headscale before installing headscale-panel, please use the script provided in the project to modify the database. Instructions

Then you need to run

headscale-panel

Set up the service manager:

# Example for Ubuntu Server: copy the systemd/headscale-panel.service file to /etc/systemd/system
systemctl daemon-reload
systemctl start headscale-panel
# Set to start on system startup
systemctl enable headscale-panel

Deploy Frontend

See in headscale-panel-ui

Two modes of operation

Standalone

In this mode, the operation of headscale will be taken over by headscale-panel. headscale and headscale-panel will work on different ports, if you want them to work on the same port, you need to use nginx or another program that can provide a reverse proxy. Here is an example

See config-example.yaml for more.

Multi

Use this mode if you want to deploy headscale and headscale-panel in separate environments

See config-example.yaml for more.

Default Administrator Account

Project Screenshots

Login User Role RolePermission Machine HeadscaleConfig Dashboard

Project Structure Overview

├─common # Common resources such as casbin, postgresql, validator, etc.
├─config # Configuration file reading using viper
├─controller # Controller layer, methods that handle route requests
├─dto # Data structures returned to the frontend
├─log # Log use zap
├─middleware # Middleware
├─model # Struct models
├─repository # Database operations
├─response # Common response encapsulations, such as Success and Fail
├─routes # All routes
├─util # Utility methods
├─task # Methods to control and communicate for headscale
└─vo # Data structures for receiving requests from the frontend

Frontend Vue Project

https://github.com/QianheYu/headscale-panel-ui.git

MIT License

Copyright (c) 2023 QianheYu