Tutorial for setting up GOST tunnel as relay server
This page shows how to turn a server into a relay for Hiddify Manager with GOST (GO Simple Tunnel). GOST is a small open-source program that forwards ports from one server to another.
A relay is a second server, usually inside your own country, that users connect to and that passes their traffic to the main Hiddify Manager server abroad. It helps when the main server’s IP is blocked or slow from your country. Read more about relays.
Why GOST instead of plain IP-Tables forwarding?
- You can point the tunnel at the main server’s domain instead of its IP; if the main server’s IP changes, you only update the DNS record.
- It runs as a system service and starts again by itself after a reboot.
- It works with every Hiddify Manager protocol, because it moves raw TCP and UDP traffic. Your proxy traffic stays encrypted by the proxy protocol itself.
An easier way
The Hiddify Relay Builder can install GOST for you from a menu.
Prerequisites
- A main server with Hiddify Manager installed. See the installation guide.
- A relay server with Ubuntu or Debian and SSH access as
root. New to SSH? See How to connect to a server with SSH. - A domain that points directly at the main server’s IP (proxy off, not through a CDN), or just the main server’s IP.
Install GOST on the relay server
This guide installs GOST v3 (the go-gost/gost project), the actively developed version of GOST.
- Connect to the relay server with SSH.
-
Install GOST with the official script. It picks the right build for the server’s processor (amd64 or arm64) and puts it in
/usr/local/bin/gost: -
Create a service file, so GOST runs in the background and after every reboot:
-
Paste this into the editor:
[Unit] Description=GOST relay to the Hiddify Manager server After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/usr/local/bin/gost -L tcp://:443/main.example.com:443 -L udp://:443/main.example.com:443 -L tcp://:80/main.example.com:80 Restart=on-failure RestartSec=3 [Install] WantedBy=multi-user.target -
Replace all three
main.example.comwith the main server’s direct domain (or its IP). Save withCtrl+Sand exit withCtrl+X. -
Start the service and make it start at every boot:
Check that it works
You should see active (running). Press q to leave. If you see failed, read the error with journalctl -u gost -n 30, fix the ExecStart line and run the two commands of step 6 again.
To forward more ports, add another -L tcp://:PORT/main.example.com:PORT to the ExecStart line; for UDP write udp:// instead of tcp://. If a firewall (for example ufw) is on on the relay server, open the same ports in it.
If you installed GOST v2 before
v2 (the ginuerzh/gost project) is only maintained now; v3 replaces it. The -L tcp://... command form is the same in both, so just run the install command above (it replaces /usr/local/bin/gost) and then sudo systemctl restart gost.
Add the relay in Hiddify Manager
- With an
Arecord, point a subdomain (for examplerelay.example.com) at the relay server’s IP. In Cloudflare keep the proxy off (DNS only). - In the panel, open Domains in the sidebar, click Add Domain, type the subdomain and click Check.
-
In the Mode step, under How is it set up?, choose Relay. Under Which TLS?, Valid TLS is usually best; since GOST forwards port 80 too, the panel can get a certificate for the relay domain.

-
If you chose Reality or Fake, enter the relay server’s IP in that domain’s Advanced › Force Configs to Use These IPs / Domains.
- Edit your subscription domain, also select the relay domain in Show configs of, and apply the changes (Actions › Apply Now).
Remove GOST from the relay server
Run these commands on the relay server:
sudo systemctl disable --now gost
sudo rm -f /etc/systemd/system/gost.service /usr/lib/systemd/system/gost.service /usr/local/bin/gost
sudo systemctl daemon-reload