You can set up sing-box as a universal server and client for VLESS Reality, Hysteria2, and TUIC simultaneously on a single VPS using a unified YAML configuration file, which, when structured correctly, can serve up to 50 users on a VPS with 4 GB RAM, managed via systemctl.
In a world where digital borders are increasingly prevalent and the need for reliable, secure access to information grows, censorship circumvention tools play a critically important role. Traditionally, providing access through multiple protocols required deploying separate servers or complex setups, which increased overhead, complicated management, and demanded more resources. However, with the advent of sing-box, this paradigm has shifted. Sing-box is a powerful, high-performance proxy server that allows you to combine the functionality of multiple protocols, such as VLESS Reality, Hysteria2, and TUIC, within a single configuration on one VPS.
This article from Valebyte.com aims to demonstrate how to configure such a universal proxy server, which not only simplifies deployment and maintenance but also provides flexible options for users. We will delve into the sing-box config structure, explore how to set up sing-box multiple protocols simultaneously, and discuss how the sing-box client can use intelligent sing-box routing rules to optimize traffic. Our goal is to provide a comprehensive guide to sing-box server setup and client configuration, showcasing its superiority and capabilities.
Why Sing-box is the Ideal Universal Proxy Server
Sing-box stands out among other proxy tools due to its modular architecture, high performance, and broad support for modern protocols. It is designed with the needs of today's internet in mind, where it's crucial not only to bypass blocks but also to ensure a stable, fast, and secure connection.
Sing-box Evolution and Advantages Over Alternatives (sing-box vs xray)
For a long time, Xray (a V2Ray fork) was the de facto standard for many users, offering powerful capabilities and support for various protocols. However, sing-box represents a new generation of tools, developed from scratch to achieve maximum efficiency and flexibility. Unlike Xray, which often required a more cumbersome configuration for complex scenarios, sing-box offers a more concise and unified approach to managing multiple protocols and features.
Key advantages of sing-box:
- Single Codebase: Sing-box is written in Go, ensuring cross-platform compatibility and high performance.
- Modularity: Its architecture allows for easy addition of new protocols and features without rewriting the entire core.
- Support for Modern Protocols: Built-in support for VLESS Reality, Hysteria2, TUIC v5, Shadowsocks, VMess, and others, including their advanced obfuscation variants.
- Performance Optimization: Sing-box demonstrates excellent metrics in resource consumption and throughput, which is especially important for high-traffic servers.
- Flexible Configuration: A powerful system of routing rules and policies allows for the creation of highly complex and efficient use cases.
The comparison of sing-box vs xray often comes down to choosing between a proven but more complex tool and a modern, more efficient, and easier-to-manage solution. For scenarios involving sing-box multiple protocols on a single server, sing-box clearly wins due to its unified configuration.
Core Components and How Sing-box Works
Sing-box operates on the principle of "inbounds → routing → outbounds."
- Inbounds: Define how sing-box accepts incoming connections. These can be various protocols (VLESS, Hysteria2, TUIC) on different ports.
- Outbounds: Define how sing-box forwards traffic. This can be a direct connection (
direct), blocking (block), or redirection through another proxy. - Routing: The core of sing-box, which, based on rules (domains, IP addresses, geolocation), decides where to direct incoming traffic. This allows for complex scenarios, such as directing traffic to local resources directly while routing all other traffic through a proxy.
To create a universal server, we will configure multiple inbounds, each listening on its own port and using its own protocol, but sharing common resources such as TLS certificates and user lists.
Preparing Your VPS for a Universal Sing-box Server
Before diving into the configuration intricacies, you need to prepare a suitable VPS and install sing-box on it.
Choosing the Right Valebyte VPS for Sing-box
For a universal server that will handle multiple protocols and potentially dozens of users, it's crucial to choose a VPS with sufficient resources. We recommend:
- RAM: Minimum 2 GB, but 4 GB is better for stable operation with a large number of concurrent connections and geobases.
- vCPU: Minimum 1 vCPU, preferably 2 vCPU.
- Disk: 20-40 GB NVMe/SSD. NVMe is preferred for faster loading and database operations.
- Network Port: 1 Gbps to ensure high throughput.
Valebyte.com offers various plans that are ideally suited for such tasks. For example, plans with 2-4 GB RAM and 2 vCPU provide excellent performance for most scenarios. To ensure maximum performance and minimize latency, choose data centers located closer to your end-users.
Basic Sing-box Installation and Dependencies
This guide assumes your VPS is running a Debian/Ubuntu-based operating system. All commands are executed as the root user or using sudo.
1. Update your system:
sudo apt update && sudo apt upgrade -y
2. Install necessary utilities (if not already present):
sudo apt install -y curl wget unzip gnupg2 ca-certificates lsb-release debian-archive-keyring
3. Install sing-box. The simplest way is to use the official installation script:
curl -sL https://raw.githubusercontent.com/SagerNet/sing-box/main/install.sh | sudo bash -s install
This script will install the latest stable version of sing-box and create a systemd unit file, which greatly simplifies service management.
4. Configure the UFW firewall (if used). Open the ports that will be used for VLESS Reality (443), Hysteria2 (e.g., 443 or 8080), and TUIC (e.g., 443 or 4443). Port 443 is mandatory for VLESS Reality.
sudo ufw allow 443/tcp comment "VLESS Reality / Hysteria2 / TUIC"
sudo ufw allow 8080/udp comment "Hysteria2 UDP"
sudo ufw allow 4443/udp comment "TUIC UDP"
sudo ufw enable
Ensure you've allowed SSH access (usually port 22): sudo ufw allow 22/tcp.
After installation, sing-box will be available as the sing-box.service. You can start and stop it using systemctl.
For more details on installing sing-box and its basic configuration for specific protocols, refer to our article sing-box on VPS: Universal Server for VLESS, Reality, and Hysteria.
Looking for a reliable server for your projects?
VPS from $10/month and dedicated servers from $9/month with NVMe, DDoS protection, and 24/7 support.
View offers →Crafting a Unified Sing-box Configuration: VLESS Reality, Hysteria2, and TUIC
The key to a universal server is a well-structured sing-box config that allows sing-box multiple protocols to operate simultaneously. We will use a single configuration file (typically /etc/sing-box/config.json or /etc/sing-box/config.yaml) to define all necessary inbounds, outbounds, and routing rules.
Configuration File Structure
Sing-box supports both JSON and YAML formats. YAML is often preferred for its readability. Here's the basic structure we'll use:
# /etc/sing-box/config.yaml
log:
level: info
timestamp: true
dns:
servers:
- 8.8.8.8
- 1.1.1.1
# ... additional DNS settings ...
inbounds:
# VLESS Reality
- type: vless
tag: vless-in
listen: ::
listen_port: 443
tls:
enabled: true
server_name: example.com # Your domain
reality:
enabled: true
handshake_server: example.com:443 # Real website domain
private_key: "YOUR_PRIVATE_KEY"
short_id: ["YOUR_SHORT_ID"]
users:
- uuid: "YOUR_UUID_1"
flow: "xtls-rprx-vision"
- uuid: "YOUR_UUID_2"
flow: "xtls-rprx-vision"
# Hysteria2
- type: hysteria2
tag: hysteria2-in
listen: ::
listen_port: 8080 # Or 443 if not occupied by VLESS
tls:
enabled: true
server_name: example.com # Your domain
certificate_path: "/etc/ssl/certs/example.com.crt" # Path to your certificate
key_path: "/etc/ssl/private/example.com.key" # Path to your private key
users:
- name: "user1"
password: "password1"
- name: "user2"
password: "password2"
# bandwidth_up: 100 Mbps
# bandwidth_down: 100 Mbps
# TUIC
- type: tuic
tag: tuic-in
listen: ::
listen_port: 4443 # Or 443 if not occupied
tls:
enabled: true
server_name: example.com # Your domain
certificate_path: "/etc/ssl/certs/example.com.crt"
key_path: "/etc/ssl/private/example.com.key"
users:
- uuid: "YOUR_UUID_3"
password: "password3"
- uuid: "YOUR_UUID_4"
password: "password4"
# congestion_control: bbr
# udp_relay_mode: native
outbounds:
- type: direct
tag: direct
- type: block
tag: block
route:
rules:
# ... routing rules ...
final: direct # Or block, if no other rules
Configuring Inbounds for VLESS Reality, Hysteria2, and TUIC Simultaneously
Let's examine the inbounds section for each protocol in detail.
VLESS Reality
VLESS Reality is a powerful protocol that uses TLS obfuscation to mask traffic as regular HTTPS, directing it to a real website. This makes it highly resistant to blocking. Its configuration requires generating a private key and a short ID.
# In the terminal, to generate Reality keys:
/usr/local/bin/sing-box generate reality-key
/usr/local/bin/sing-box generate reality-short-id
# Copy the private_key and short_id into the config.
# VLESS Reality Inbound
- type: vless
tag: vless-in
listen: ::
listen_port: 443 # Standard HTTPS port
tls:
enabled: true
server_name: example.com # Your domain
reality:
enabled: true
handshake_server: example.com:443 # Real website domain to which traffic will be proxied
private_key: "YOUR_GENERATED_PRIVATE_KEY"
short_id: ["YOUR_GENERATED_SHORT_ID"]
users:
- uuid: "YOUR_UUID_1" # Generate UUID: sing-box generate uuid
flow: "xtls-rprx-vision" # Recommended flow for Reality
- uuid: "YOUR_UUID_2"
flow: "xtls-rprx-vision"
Important: The handshake_server must be a real, operational website that will respond to initial requests. The server_name should match this domain. More details on VLESS Reality configuration can be found in our article on sing-box on VPS.
Hysteria2
Hysteria2 is a protocol optimized for UDP traffic, ideal for streaming, online gaming, and other latency-sensitive applications. It also uses TLS for obfuscation.
# Hysteria2 Inbound
- type: hysteria2
tag: hysteria2-in
listen: ::
listen_port: 8080 # Or 443 if VLESS Reality uses another port
tls:
enabled: true
server_name: example.com # Your domain
certificate_path: "/etc/ssl/certs/example.com.crt" # Path to your full certificate
key_path: "/etc/ssl/private/example.com.key" # Path to the certificate's private key
users:
- name: "user1"
password: "password1"
- name: "user2"
password: "password2"
# bandwidth_up: 100 Mbps # Optional: bandwidth limit
# bandwidth_down: 100 Mbps # Optional: bandwidth limit
Hysteria2 requires a valid TLS certificate. We recommend using Let's Encrypt. You can obtain it using Certbot: sudo apt install certbot && sudo certbot certonly --standalone -d example.com. After obtaining the certificates, configure them for automatic renewal. More details on Hysteria2 and its configuration can be found in the article Hysteria2 on VPS: Installation and Configuration for DPI Evasion in 2026.
TUIC
TUIC (TCP User Datagram Internet Connection) is a relatively new protocol that also uses UDP, but with an emphasis on improving the performance of TCP-like traffic over UDP. It is designed for high resistance to packet loss and low latency.
# TUIC Inbound
- type: tuic
tag: tuic-in
listen: ::
listen_port: 4443 # Or 443 if VLESS Reality and Hysteria2 use other ports
tls:
enabled: true
server_name: example.com # Your domain
certificate_path: "/etc/ssl/certs/example.com.crt"
key_path: "/etc/ssl/private/example.com.key"
users:
- uuid: "YOUR_UUID_3"
password: "password3"
- uuid: "YOUR_UUID_4"
password: "password4"
# congestion_control: bbr # Optional: congestion control algorithm
# udp_relay_mode: native # Optional: UDP relay mode
Like Hysteria2, TUIC requires a valid TLS certificate. A detailed guide to TUIC v5 is available in the article TUIC v5 on VPS in 2026: Setup, Tuning, and Comparison with Hysteria2.
Shared User Management and TLS Certificates
In the examples provided, each inbound has its own list of users. For simplified management, shared user lists can be used if the protocol allows it (e.g., VLESS by UUID). For Hysteria2 and TUIC, which use their own authentication mechanisms, user lists will be separate but all managed within a single sing-box config file.
Regarding TLS certificates, for Hysteria2 and TUIC, which use standard TLS, the same Let's Encrypt certificate (for example.com) can be used. VLESS Reality uses its own mechanism with a private_key and short_id, which does not require external certificates on the sing-box server, but does require specifying a server_name and handshake_server corresponding to a real domain for which you have a certificate.
It is important to ensure that all ports used by the protocols are open in the VPS firewall.
Routing Rules and Geobases: Smart Sing-box Client Configuration
The client-side of sing-box is no less important than the server-side. Correctly configured sing-box routing rules allow for traffic optimization, selective bypass of blocks, and improved overall performance. The client configuration also allows for using sing-box multiple protocols, automatically switching between them.
Client Configuration: The Foundation of Smart Routing
The sing-box client configuration is also a YAML file, but with a focus on outbounds (which in this case are the servers we connect to) and route.
# Example sing-box client config
log:
level: info
dns:
servers:
- 8.8.8.8
- 1.1.1.1
# ...
inbounds:
- type: tun
tag: tun-in
# ... TUN interface settings ...
- type: mixed # HTTP/SOCKS5 proxy
tag: mixed-in
listen: 127.0.0.1
listen_port: 10808
outbounds:
- type: vless
tag: vless-out
server: your_vps_ip_or_domain.com
server_port: 443
uuid: "YOUR_UUID_1"
flow: "xtls-rprx-vision"
tls:
enabled: true
server_name: example.com # Domain specified on the server for Reality
reality:
enabled: true
public_key: "SERVER_PUBLIC_KEY" # Generated from the server's private key
short_id: "YOUR_SHORT_ID"
- type: hysteria2
tag: hysteria2-out
server: your_vps_ip_or_domain.com
server_port: 8080
password: "password1"
tls:
enabled: true
server_name: example.com
insecure: false # Always false in production
- type: tuic
tag: tuic-out
server: your_vps_ip_or_domain.com
server_port: 4443
uuid: "YOUR_UUID_3"
password: "password3"
tls:
enabled: true
server_name: example.com
insecure: false
- type: direct
tag: direct
- type: block
tag: block
route:
rule_set:
- type: remote
tag: geoip-local
url: https://raw.githubusercontent.com/SagerNet/sing-box-rules/main/geoip/ru.srs
interval: 86400 # Update daily
- type: remote
tag: geosite-local
url: https://raw.githubusercontent.com/SagerNet/sing-box-rules/main/geosite/ru.srs
interval: 86400
rules:
- rule_set: geoip-local
outbound: direct
- rule_set: geosite-local
outbound: direct
# ... other rules ...
- inbound: tun-in
outbound: proxy-group # Use group for auto-switching
- inbound: mixed-in
outbound: proxy-group
policy_groups:
- tag: proxy-group
type: urltest # Automatically selects the fastest/most available proxy
interval: 60 # Check every 60 seconds
timeout: 5000 # Check timeout 5 seconds
url: http://cp.cloudflare.com/generate_204
strategy: prefer-fastest
outbounds:
- vless-out
- hysteria2-out
- tuic-out
Practical Routing Rules: Bypassing Domains and Directing Local Traffic
The route section allows you to create powerful sing-box routing rules. By using geosite and geoip geobases, traffic can be automatically directed.
- Direct Local Traffic: For accessing local resources without proxying, to reduce latency and avoid potential access issues with domestic services.
- Bypass Domains: Specific domains that should go directly or through a particular proxy.
Example rules:
route:
rule_set:
# Load geobases for local regions (e.g., Russia)
- type: remote
tag: geoip-local
url: https://raw.githubusercontent.com/SagerNet/sing-box-rules/main/geoip/ru.srs
interval: 86400 # Update daily
- type: remote
tag: geosite-local
url: https://raw.githubusercontent.com/SagerNet/sing-box-rules/main/geosite/ru.srs
interval: 86400
# Load geobase for ads and trackers
- type: remote
tag: geosite-ads
url: https://raw.githubusercontent.com/SagerNet/sing-box-rules/main/geosite/category-ads-all.srs
interval: 86400
rules:
# Traffic to local IP addresses goes direct
- rule_set: geoip-local
outbound: direct
# Traffic to local domains (e.g., country-specific TLDs, yandex.ru) goes direct
- rule_set: geosite-local
outbound: direct
# Block ads and trackers
- rule_set: geosite-ads
outbound: block
# Rule for private IP addresses (LAN) - always direct
- ip_is_private: true
outbound: direct
# If nothing else matches, all other traffic goes through the proxy group
- outbound: proxy-group
Automatic Failover and Load Balancing
Sing-box allows you to configure outbound connection groups (policy_groups) that can automatically switch between available servers or protocols. This is especially useful when you are using sing-box multiple protocols and want the client to automatically select the best one.
policy_groups:
- tag: proxy-group
type: urltest # Checks availability and latency via URL
interval: 60 # Check every 60 seconds
timeout: 5000 # Check timeout 5 seconds
url: http://cp.cloudflare.com/generate_204 # URL for availability check
strategy: prefer-fastest # Choose the fastest
outbounds:
- vless-out
- hysteria2-out
- tuic-out
- tag: fallback-group
type: fallback # Switches to the next if the current one is unavailable
outbounds:
- hysteria2-out
- vless-out
- tuic-out
In this example, the proxy-group will constantly check the availability and speed of VLESS, Hysteria2, and TUIC, automatically switching to the fastest. If any protocol becomes unavailable, the client will automatically switch to another. This ensures a high level of reliability and fault tolerance.
For more detailed configuration of the sing-box client and its integration with a system-wide proxy on Linux, refer to our article Linux Desktop and Your Own VPS: sing-box and Xray as a System Proxy (although the article mentions Xray, the principles of sing-box client configuration remain similar).
Managing and Monitoring Sing-box on Your VPS
Effective management and monitoring of your sing-box server are crucial for maintaining its stable operation and quickly responding to potential issues.
Starting and Managing the Sing-box Service with systemd
After installing sing-box using the official script, it is registered as the system service sing-box.service. This allows you to manage it using systemctl.
- Starting the service:
sudo systemctl start sing-box - Stopping the service:
sudo systemctl stop sing-box - Restarting the service:
sudo systemctl restart sing-boxNote that a full restart may briefly interrupt connections.
- Checking service status:
sudo systemctl status sing-box - Enabling autostart on system boot:
sudo systemctl enable sing-box - Disabling autostart:
sudo systemctl disable sing-box
The default configuration file is located at /etc/sing-box/config.json or /etc/sing-box/config.yaml. All configuration changes require a service restart or reload.
Logging and Troubleshooting
Sing-box generates logs that help monitor its operation and diagnose problems. By default, logs are output to journald and can be viewed using journalctl.
# View the latest sing-box logs
sudo journalctl -u sing-box -f
# View logs for a specific period
sudo journalctl -u sing-box --since "2023-01-01" --until "2023-01-02"
# View logs with a specific level (e.g., error)
sudo journalctl -u sing-box -p err
In the sing-box configuration, you can set the logging level (log.level: debug/info/warn/error/fatal) and output logs to a file, which is convenient for long-term analysis:
log:
level: info
timestamp: true
output: "/var/log/sing-box.log" # Specify the path for the log file
After changing this setting, remember to restart sing-box.
Updating Sing-box Without Dropping Connections
Updating sing-box without dropping active connections is an important feature for maintaining service continuity. Sing-box supports "hot" reloading of configuration and binary updates.
1. Updating the binary: The sing-box installation script is also used to update to the latest version:
curl -sL https://raw.githubusercontent.com/SagerNet/sing-box/main/install.sh | sudo bash -s install
After updating the binary, sing-box will not automatically restart. To apply the new version without dropping connections, use the reload command:
sudo systemctl reload sing-box
This command sends a SIGHUP signal to the sing-box process, which will attempt to reload the configuration and update its binary, while preserving active connections. If the configuration has changed, it will also be applied.
2. Reloading the configuration: If you have only changed the configuration file (config.yaml), you can also use reload:
sudo systemctl reload sing-box
This will apply the new settings without interrupting service operation. If reload does not work or errors occur, a full restart sudo systemctl restart sing-box will be required.
Choosing a VPS for Sing-box: Scaling for Performance
The performance of your universal sing-box server directly depends on the chosen VPS. The right VPS configuration will ensure stable operation for all your users.
Factors Affecting Performance
When choosing a VPS for sing-box, several key factors should be considered:
- Number of Users: The more concurrent users, the more resources will be required.
- Protocols: Some protocols (e.g., VLESS Reality) can be more resource-intensive due to cryptographic operations.
- Traffic Intensity: High throughput and a large number of small connections demand more CPU and RAM.
- Geobases and Routing Rules: Using extensive geobases and complex routing rules increases RAM and CPU consumption.
- Disk Subsystem: Fast SSD or NVMe disks are preferred for storing logs and geobases.
For 50 concurrent users, 4 vCPU, 8 GB RAM, and an 80 GB NVMe disk are sufficient.
| Users | vCPU | RAM | Disk | Port | Estimated Valebyte Price/Month (March 2024) |
|---|---|---|---|---|---|
| Up to 10 | 1 | 2 GB | 20 GB NVMe | 1 Gbps | from $5 |
| 10-25 | 2 | 4 GB | 40 GB NVMe | 1 Gbps | from $10 |
| 25-50 | 4 | 8 GB | 80 GB NVMe | 1 Gbps | from $20 |
| 50-100 | 6 | 16 GB | 160 GB NVMe | 1 Gbps | from $40 |
These estimated prices and configurations will help you choose a suitable VPS plan from Valebyte.com. It's always better to have a small resource buffer than to encounter performance issues.
When to Choose Which Protocol: A Client's Guide
A universal sing-box server provides flexibility in protocol choice. But when is which protocol best to use?
Protocol Comparison Table
| Protocol | When the client chooses it | Key Features |
|---|---|---|
| VLESS Reality |
|
|
| Hysteria2 |
|
|
| TUIC |
|
|
Thanks to the urltest feature in the sing-box client configuration, you won't have to manually select a protocol. The client will automatically determine which of the available protocols on your universal proxy server is the fastest and most stable at any given moment, automatically switching between VLESS Reality, Hysteria2, and TUIC to ensure the best experience.
Frequently Asked Questions
1. How many users can one sing-box server with multiple protocols serve simultaneously?
A single sing-box server configured for VLESS Reality, Hysteria2, and TUIC can serve anywhere from 10 to 100+ users, depending on the VPS resources. For comfortable operation with 50 users, a VPS with 4 vCPU, 8 GB RAM, and an NVMe disk providing 1 Gbps throughput is recommended.
2. Do I need a separate domain for each protocol when using sing-box with multiple protocols?
No, not necessarily. You can use a single domain for all protocols that utilize TLS (Hysteria2, TUIC). For VLESS Reality, one domain is also required as the handshake_server for traffic obfuscation, and this can be the same domain. The key is to correctly configure TLS certificates and ports.
3. How do I update sing-box without dropping connections?
To update the sing-box binary, use the official installation script, then run sudo systemctl reload sing-box. This command allows the sing-box process to reload its configuration and, if necessary, update its binary while preserving active connections. If only the configuration has changed, sudo systemctl reload sing-box is sufficient.
4. What is the main advantage of sing-box vs xray for multi-protocol setup?
The main advantage of sing-box lies in its modern, modular architecture and more unified configuration, which simplifies the simultaneous setup and management of multiple protocols (VLESS Reality, Hysteria2, TUIC) within a single file. Sing-box also demonstrates excellent performance and more active development of new features compared to Xray.
5. Why are geobases needed in sing-box routing rules?
Geobases (geosite and geoip) in sing-box routing rules allow for automatic identification of the geographical origin of domains and IP addresses. This enables directing traffic to local resources (e.g., country-specific domains) directly, bypassing the proxy, while all other traffic goes through the proxy. This optimizes access speed and ensures censorship circumvention only where necessary.
Conclusion
Utilizing sing-box as a universal server for VLESS Reality, Hysteria2, and TUIC on a single VPS presents a powerful and efficient solution for censorship circumvention and flexible internet access. This sing-box server setup significantly simplifies management, reduces resource consumption, and provides users with a wide range of protocols with automatic switching. We recommend using a Valebyte.com VPS with a minimum of 4 GB RAM and 2 vCPU for stable operation with several dozen users, ensuring high performance and reliability for your universal proxy server.
NVMe VPS with 60-second activation: full root access, 20+ locations, pay by card or crypto.
Choose a plan