Hysteria2 in m-ui: from certificate to a multi-server line
Hysteria2 is the protocol most people pick first for lossy or throttled links: QUIC-based, aggressive on retransmission, and simple for clients. Here is exactly what setting it up in m-ui involves.
1. A certificate, real or self-signed
Hysteria2 requires TLS. With a domain, Certificate → Issue gets a Let's Encrypt certificate (HTTP-01 or Cloudflare DNS-01) that renews itself. Without one, Certificate → Self-sign is one click; m-ui then marks the subscription so clients allow the insecure certificate (Clash Meta's skip-cert-verify, sing-box's insecure). Both paths are first-class; the dashboard's Quick Start accepts either.
2. The Hysteria2 line
Lines → Quick add → Hysteria2. The preset selects the protocol, TLS mode "certificate", and a free five-digit UDP port that no other line, the panel or another process on the server is using. The form then offers:
| Field | What it does |
|---|---|
| Port | The UDP listen port. Open it on the firewall (UDP, not TCP). |
| Upload / download Mbps | Bandwidth hints handed to sing-box; 0 lets the congestion controller decide. Set them close to the server's real line rate if clients report unstable speed. |
| Obfuscation password | Enables Salamander obfuscation with that password; clients receive it in the subscription. Leave empty for plain QUIC. |
| Port hopping | A range such as 20000-30000; see below. |
| Exit | Direct, or one of your upstreams (WARP, a relay). |
| Servers | Which servers this line is deployed to — all, or a subset. |
Saving renders the full configuration and hands it to sing-box's parser before anything is committed; a bad combination is rejected with sing-box's own message. The data plane then restarts for this new listener — with rollback to the previous configuration if the new one fails to start.
3. Port hopping
Hysteria2 port hopping lets clients rotate the destination UDP port inside a range, which helps where a single UDP flow gets throttled after a while. In m-ui you type the range once on the line. On each server the line is deployed to, m-ui installs a firewall redirect rule so every port in the range lands on the line's real listen port, and the subscription tells clients about the range (Clash Meta ports, sing-box and Shadowrocket equivalents). Removing the range removes the rule. Nothing to script by hand; the range is validated and normalised when you save.
4. Users
Tick "assign to all users" on the line, or assign per user. Each user already has a Hysteria2 password; quota, expiry, device limit and speed limits apply to this line like any other. Disabling a user swaps the inbound user table without restarting the listener, so other Hysteria2 sessions stay up.
5. What clients receive
- Clash Meta / Mihomo (
?format=clash): ahysteria2proxy with password, obfs, port range andskip-cert-verifywhen the certificate is self-signed. - sing-box (
?format=json): a complete outbound-plus-rules configuration for SFA, SFI and desktop sing-box. - Universal links (default):
hysteria2://URIs for Shadowrocket, nextin, Karing and others.
All three come from the same address; the landing page offers one-tap import buttons and a QR code.
6. The same line on several servers
Deploy the line to all servers or pick some. The master pushes the line, the certificate settings and the user table to every node within 5 seconds; each node listens on the same port with its own certificate and its own port-hopping rule. The user's subscription then lists Hysteria2 – Tokyo, Hysteria2 – Frankfurt and so on, and their client picks by latency. Traffic from every server counts once against the user's quota.
Operations notes
- Hysteria2 is UDP: cloud firewalls and security groups must allow UDP on the port (and the hop range).
- Bandwidth hints matter more than on TCP protocols: if clients see erratic speed, set upload / download close to the server's real line rate.
- Per-user speed limits are enforced in the data plane and work with Hysteria2 like any other protocol.
- Switching a user off, changing their password or moving the line to another exit never restarts the listener.