Back to articles
DevOps & Systems

Complete Sing Box Client-Server Configuration Guide for Modern Network Protocols

This comprehensive guide details the end-to-end setup of Sing Box on both client and server systems to leverage modern network protocols such as VLESS, XTLS, HTTP/3, QUIC, and...

DPTCloud Engineering6 min read
Complete Sing Box Client-Server Configuration Guide for Modern Network Protocols

This comprehensive guide details the end-to-end setup of Sing Box on both client and server systems to leverage modern network protocols such as VLESS, XTLS, HTTP/3, QUIC, and WireGuard. The guide covers basic setup, advanced configuration, security hardening, performance optimization, and connection testing, making it ideal for DevOps professionals and advanced users seeking a flexible, secure, and high-performance networking solution. Sing Box is an open-source networking toolkit that integrates multiple modern communication protocols, enabling the construction of adaptable, secure, and high-efficiency network systems. Configuring Sing Box in a client-server model allows full utilization of modern network protocols to improve connection speed, reduce latency, and enhance anti-censorship capabilities.

Introduction to Sing Box and Benefits of Client-Server Configuration

Sing Box is an open-source networking tool developed by the Sing-Box project, integrating modern communication protocols such as VLESS, VMess, Trojan, WireGuard, HTTP/3, and QUIC. With a modular architecture and multi-platform support, Sing Box enables users to build flexible, secure, and high-performance network systems. Configuring Sing Box on both client (user device) and server (host) allows full exploitation of modern network protocols, improving connection speed, reducing latency, and increasing anti-blocking capability. This guide provides a comprehensive overview of setting up Sing Box client-server, including both basic and advanced configurations for the latest protocols.

Prerequisites and Environment Setup

To configure Sing Box, you need a server and a client device. The server requires a Linux operating system (Ubuntu/Debian/RHEL) and at least 1 GB of RAM. The client can be a personal computer, server, or mobile device. First, download Sing Box from the official website: https://github.com/SagerNet/sing-box/releases. Download the version compatible with your operating system (Linux, Windows, macOS, Android, iOS). After downloading, extract the executable and place it in the appropriate directory (typically /usr/local/bin). On the server, ensure that the required ports (e.g., 443, 80, 8888) are open in the firewall. You can use NVMe Cloud VPS for Docker, Nginx & Databases to obtain a stable and high-performance server.

Sing Box Server Configuration

On the server, create a Sing Box configuration file (typically config.json). Below is a basic configuration sample for the VLESS protocol with XTLS and HTTP/3:

{
  "log": {
    "level": "info",
    "output": "/var/log/sing-box.log"
  },
  "inbounds": [
    {
      "type": "vless",
      "tag": "vless-in",
      "listen": "::",
      "listen_port": 443,
      "listen_ip": "0.0.0.0",
      "users": [
        {
          "uuid": "your-uuid-here",
          "flow": "xtls-rprx-vision"
        }
      ],
      "tls": {
        "enabled": true,
        "server_name": "your-domain.com",
        "certificate": "auto"
      },
      "transport": {
        "type": "quic",
        "quic": {
          "max_idle_timeout": "100s",
          "max_early_data": 2048
        }
      }
    }
  ],
  "outbounds": [
    {
      "type": "direct"
    }
  ]
}

Replace your-uuid-here with a random UUID (you can generate one using the uuidgen command or online). Replace your-domain.com with your domain name. This configuration uses VLESS with the xtls-rprx-vision flow to support XTLS and QUIC to leverage HTTP/3. To test the configuration, run the command: ./sing-box run -c config.json. If no errors occur, Sing Box will start running. You can use Bien VPS Thanh Super Router: Guide to Setting Up OpenWRT VPN and Adblock for Home Networks to learn more about using a VPS as a network hub.

Sing Box Client Configuration

On the client, create a similar configuration file. Below is a client configuration sample for the VLESS protocol:

{
  "log": {
    "level": "info",
    "output": "/var/log/sing-box-client.log"
  },
  "inbounds": [
    {
      "type": "tun",
      "tag": "tun-in",
      "inet4_address": "172.19.0.1/24",
      "auto_route": true,
      "strict_route": true
    }
  ],
  "outbounds": [
    {
      "type": "vless",
      "tag": "vless-out",
      "server": "your-server-domain.com",
      "server_port": 443,
      "uuid": "your-uuid-here",
      "flow": "xtls-rprx-vision",
      "tls": {
        "enabled": true,
        "server_name": "your-server-domain.com",
        "insecure": false
      },
      "transport": {
        "type": "quic",
        "quic": {
          "max_idle_timeout": "100s"
        }
      }
    },
    {
      "type": "direct"
    }
  ],
  "route": {
    "rules": [
      {
        "outbound": "vless-out",
        "domain": [
          "geosite:geolocation-!cn"
        ]
      },
      {
        "outbound": "direct",
        "domain": [
          "geosite:cn"
        ]
      }
    ]
  }
}

Replace your-server-domain.com and your-uuid-here with the corresponding values from the server. This configuration uses a TUN interface to create a virtual network and routes traffic out via VLESS. The routing rules allow access to websites outside China (geosite:geolocation-!cn) through the proxy, while websites within China (geosite:cn) are accessed directly. Run Sing Box on the client with the command: ./sing-box run -c config-client.json.

Testing and Troubleshooting

To test the connection, you can use the ping or curl command to check connectivity to the server. Additionally, check the Sing Box logs to see if there are any errors. If you cannot connect, check the following points:

  • Are the ports on the server open in the firewall (use the command sudo ufw status or sudo firewall-cmd --list-all);
  • Is the domain correctly pointed to the server's IP (use the command nslookup your-domain.com);
  • Are the UUID and TLS configuration correct.

If necessary, you can change the protocol or transport configuration to match the network environment. Additionally, you can refer to the guide on Guide to Setting Up Global Server Load Balancing GSLB with PowerDNS and GeoIP to learn more about network routing and load balancing.

Performance Optimization and Security

Sing Box supports many advanced features to optimize performance and security. Important features include:

  • HTTP/3 and QUIC: Use the HTTP/3 and QUIC protocols to improve connection speed and reduce latency, especially useful for high-speed applications such as video, audio, and gaming.
  • XTLS: Integrate XTLS to secure connections and more effectively resist blocking compared to traditional protocols.
  • WireGuard: Use WireGuard to create secure and high-performance VPN connections, especially suitable for applications requiring high security.
  • Geolocation routing: Use geosite to route traffic based on geographical location, helping to access faster and avoid geographical restrictions.

To optimize performance, you can adjust parameters such as max_idle_timeout, max_early_data, and auto_route in the configuration. Additionally, you can use tools like Configure VPS as WebRTC SFU Media Server with LiveKit: Infrastructure from Host to Optimize for Startups to optimize network performance for specific applications.

References

To learn more about Sing Box and modern network protocols, you can refer to the official documentation and community guides:

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478