Skip to content

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.

Users connect to the relay server, and the relay forwards their traffic to the main server with GOST

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.

  1. Connect to the relay server with SSH.
  2. 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:

    bash <(curl -fsSL https://github.com/go-gost/gost/raw/master/install.sh) --install
    
  3. Create a service file, so GOST runs in the background and after every reboot:

    sudo nano /etc/systemd/system/gost.service
    
  4. 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
    
  5. Replace all three main.example.com with the main server’s direct domain (or its IP). Save with Ctrl+S and exit with Ctrl+X.

  6. Start the service and make it start at every boot:

    sudo systemctl daemon-reload
    sudo systemctl enable --now gost
    

Check that it works

sudo systemctl status gost

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

  1. With an A record, point a subdomain (for example relay.example.com) at the relay server’s IP. In Cloudflare keep the proxy off (DNS only).
  2. In the panel, open Domains in the sidebar, click Add Domain, type the subdomain and click Check.
  3. 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.

    The Add a Domain window: Relay mode and Valid TLS

  4. If you chose Reality or Fake, enter the relay server’s IP in that domain’s Advanced › Force Configs to Use These IPs / Domains.

  5. 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

Last update: December 4, 2026

Comments