Musixal / Backhaul

Lightning-fast reverse tunneling solution for NAT traversal, optimized for handling massive concurrent connections with tcp, tcpmux, ws, wsmux, wss and wssmux support.
https://gozar_xray.t.me
GNU Affero General Public License v3.0
158 stars 26 forks source link

Backhaul

Welcome to the Backhaul project! This project provides a high-performance reverse tunneling solution optimized for handling massive concurrent connections through NAT and firewalls. This README will guide you through setting up and configuring both server and client components, including details on different transport protocols.


Table of Contents

  1. Introduction
  2. Installation
  3. Usage
  4. Generating a Self-Signed TLS Certificate with OpenSSL
  5. Running backhaul as a service
  6. FAQ
  7. License
  8. Donation

Introduction

This project offers a robust reverse tunneling solution to overcome NAT and firewall restrictions, supporting various transport protocols. It’s engineered for high efficiency and concurrency.

Installation

  1. Download the latest release from the GitHub releases page.
  2. Extract the archive (adjust the filename if needed):

    tar -xzf backhaul_linux_amd64.tar.gz
  3. Run the executable:

    ./backhaul
  4. You can also build from source if preferred:

    git clone https://github.com/musixal/backhaul.git
    cd backhaul
    go build
    ./backhaul

Usage

The main executable for this project is backhaul. It requires a TOML configuration file for both the server and client components.

Configuration Options

To start using the solution, you'll need to configure both server and client components. Here’s how to set up basic configurations:

Detailed Configuration

TCP Configuration

TCP Multiplexing Configuration

WebSocket Configuration

Secure WebSocket Configuration

WS Multiplexing Configuration

WSS Multiplexing Configuration

Generating a Self-Signed TLS Certificate with OpenSSL

To generate a TLS certificate and key, you can use tools like OpenSSL. Here’s a step-by-step guide on how to create a self-signed certificate and key using OpenSSL:

Step 1: Install OpenSSL

If you don't already have OpenSSL installed, you can install it using your system's package manager.

Create a Certificate Signing Request (CSR) using the private key. This CSR is used to generate the SSL certificate:

openssl req -new -key server.key -out server.csr

You will be prompted to enter information for the CSR. For the common name (CN), use the domain name or IP address where your server will be hosted. Example:

Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:California
Locality Name (eg, city) []:San Francisco
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company Name
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:example.com
Email Address []:

Step 4: Generate a Self-Signed Certificate

Use the CSR and private key to generate a self-signed certificate. Specify the validity period (in days):

openssl x509 -req -in server.csr -signkey server.key -out server.crt -days 365

This will generate a certificate named server.crt, valid for 365 days.

Recap of the Files Generated:

Running backhaul as a service

To create a service file for your backhaul project that ensures the service restarts automatically, you can use the following template for a systemd service file. Assuming your project runs a reverse tunnel and the main executable file is located in a certain path, here's a basic example:

  1. Create the service file /etc/systemd/system/backhaul.service:
[Unit]
Description=Backhaul Reverse Tunnel Service
After=network.target

[Service]
Type=simple
ExecStart=/root/backhaul -c /root/config.toml
Restart=always
RestartSec=3
LimitNOFILE=1048576

[Install]
WantedBy=multi-user.target
  1. After creating the service file, enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable backhaul.service
sudo systemctl start backhaul.service
  1. To verify if the service is running:
    sudo systemctl status backhaul.service
  2. View the most recent log entries for the backhaul.service unit:
    journalctl -u backhaul.service -e -f

FAQ

Q: How do I decide which transport protocol to use?

License

This project is licensed under the AGPL-3.0 license. See the LICENSE file for details.

Donation

Crypto donation button by NOWPayments
</a>

Stargazers over time

Stargazers over time