Skip to content

Configuration examples ​

Prepare a local environment ​

Follow the quick start to run the server and a provider client on the same host. Add these settings to the server's app.yml and restart it. Quick start

yaml
native_bind: 127.0.0.1

In Resources → Port Resources, register ports 18080 and 18081 and grant access to the corresponding account or provider if needed. Click Test in the port's row to check whether it is Available, In Use, or Occupied for TCP and UDP. The server attempts to bind the selected port before it saves a new native mapping. The provider connects to the internal target. The gateway listens on the external port.

The Python HTTP and UDP targets on this page read application data directly. Leave Forward source address off for the same-protocol native mappings, web reverse proxy routes, and TCPMUX routes in these examples. Enable it for targets that support the binary HAProxy PROXY protocol v2. TCP sends the header once at the start of the connection. Native UDP prepends a header to each forwarded datagram. On Linux, macOS, and Windows, a native UDP wildcard listener can also obtain the actual destination IP of each datagram.

Save frequently used internal addresses and ports under Resources → Common Targets and select them when filling out a tunnel form. Common targets

Native TCP mapping ​

Use Python 3 to serve an empty folder over HTTP.

sh
mkdir tunnel-demo-http
python -m http.server 8000 --bind 127.0.0.1 --directory tunnel-demo-http

Under Resources → Tunnel Mappings, create a native mapping named HTTP demo with the mapping identifier /demo-tcp. Set both protocols to TCP, select listen port 18080 and the target client, and set the target to 127.0.0.1:8000. Wait for the mapping to take effect, then connect to the gateway port.

sh
curl --fail --noproxy '*' http://127.0.0.1:18080/

Native UDP mapping ​

Save this script as udp_echo.py and run python udp_echo.py.

python
import socket

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as listener:
    listener.bind(("127.0.0.1", 8001))
    while True:
        payload, source = listener.recvfrom(2048)
        listener.sendto(payload, source)

Create a native mapping named UDP echo with the mapping identifier /demo-udp. Set both protocols to UDP, select listen port 18081 and the target client, and set the target to 127.0.0.1:8001. After the mapping takes effect, run the following code. It prints tunnel-check.

python
import socket

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as probe:
    probe.settimeout(5)
    probe.sendto(b"tunnel-check", ("127.0.0.1", 18081))
    print(probe.recvfrom(2048)[0].decode())

Forward across protocols to HTTP or WebSocket ​

Choose TCP or UDP for ingress and HTTP, HTTPS, WS, or WSS for the target. A TCP ingress targeting UDP or a web protocol uses a 2-byte unsigned big-endian length followed by up to 65,507 payload bytes. Replies use the same framing. A UDP ingress treats each datagram as one message.

Register port 18083 and create a native mapping named UDP to HTTP with the identifier /demo-udp-http, UDP ingress and HTTP as the target protocol. Select listen port 18083 and the client running the Python server. Set the target to 127.0.0.1:8000. Set the request path to /, select GET and URL parameters, and enter payload as the parameter name. Change the port in the UDP check above to 18083. The target receives /?payload=tunnel%2Dcheck, and the reply datagram contains the page body from the Python server.

HTTP(S) paths can include existing query parameters. GET and HEAD use URL parameters. Other methods can also send a raw body, JSON, a URL-encoded form, or multipart form data. JSON encodes the payload as unpadded Base64URL. WS/WSS opens a GET handshake at the configured path and sends each incoming message as a binary WebSocket message.

Under Target request headers for HTTP(S) or Handshake request headers for WS(S), add X-Real-IP from Source IP, X-Real-Port from Source port, or X-Environment with the fixed value demo. The native listener obtains the source from the incoming connection or datagram. For native mapping targets that use HTTPS or WSS, the client uses both public and deployment trust roots and verifies the hostname from the target address. The reverse-proxy plugin uses a separate strict TLS profile for HTTPS upstreams. Plugin TLS Framing implementation

Web Reverse Proxy ​

  1. Register and enable port 62500 under Resources → Port Resources and grant access to the corresponding account or provider if needed.
  2. Register and assign app.example.test under Resources → Domains and Certificates. For public access, point DNS at the application ingress.
  3. Create and name a web reverse proxy route under Mappings → Route Tunnels → Business Routes. Select 62500 from the port pool, choose the domain, set the path prefix to /, and select the target client. Set the destination address to 127.0.0.1 and the target port to 8000. Enable the route, then check the page.
sh
curl --fail --noproxy '*' --resolve app.example.test:62500:127.0.0.1 http://app.example.test:62500/

Multiple routes for pages, APIs, and standard WebSockets can share a port and route by domain and path. HTTPS and WSS use the same TCP listener. Upload an externally issued ML-DSA-87 certificate chain and matching private key under Domains and Certificates, then turn on HTTPS for the route. The certificate SAN must cover the business domain.

To use HTTP/3, turn on HTTPS first, then enable HTTP/3 and ensure the same port is available on UDP. For direct public access, allow 62500/TCP and 62500/UDP.

sh
curl --fail --noproxy '*' --cacert ./pqc-business-root.pem --resolve app.example.test:62500:127.0.0.1 https://app.example.test:62500/

Use a curl TLS backend with ML-DSA-87 authentication and MLKEM1024 and TLS_AES_256_GCM_SHA384 support. The --cacert argument points to the business certificate's trust root. To verify HTTP/3, use a build that also supports HTTP/3 and add --http3-only.

When Nginx handles TLS, issue and renew the public site certificate at Nginx. Forward to the business TCP listener and retain the Host and WebSocket upgrade headers. Tunnel serves its management Web UI over HTTP on 9650/TCP and device enrollment over PQC HTTP/3 on 9650/UDP. Application listeners

Configure forwarded request and response headers ​

Edit the web reverse proxy route. Under Forward request headers, add X-Upstream-Request-ID, choose Original request header, and reference X-Request-ID. Under Forward response headers, add X-Request-ID and reference the same original header. Run the following command and check that the response contains X-Request-ID: demo-01.

sh
curl --fail --noproxy '*' --include --header 'X-Request-ID: demo-01' \
  --resolve app.example.test:62500:127.0.0.1 http://app.example.test:62500/

Rules also accept a fixed value or the actual source IP or port. Add a request header rule for Host to set the upstream host. If the referenced request header is absent, the destination header keeps its existing value. The gateway strips client-supplied forwarding headers before it evaluates the rules. With gateway Basic authentication enabled, it also removes the incoming Authorization header before rule evaluation. Only accounts that can edit the corresponding configuration can read fixed values.

HTTPS passthrough ​

Set https_proxy on the server, for example https_proxy: "127.0.0.1:62502". In Business Routes, choose HTTPS passthrough (target handles TLS). Register and select app.example.test, then select the client and the internal service that listens for TLS. The target holds the application certificate and completes the TLS handshake. Keep source address forwarding off unless the target accepts a PROXY v2 header before the TLS handshake. The gateway routes connections by TLS SNI. To route by URL path or modify HTTP headers at the gateway, enable HTTPS on the web reverse proxy described above.

Forward WebSocket messages to TCP or UDP ​

  1. Set http_proxy: "127.0.0.1:18082" on the server and restart it. Point app.example.test at the gateway. Register port 18082 in Port Resources and grant access to the corresponding account or provider if needed.
  2. Under Mappings → Route Tunnels → WebSocket TCP/UDP, add a WS entry for the domain and port.
  3. In Details → URL Paths, add /echo, select the provider and UDP, and set the target to 127.0.0.1:8001. Connect to ws://app.example.test:18082/echo to check the binary echo.

Each path can have up to eight TCP or UDP targets. Every WebSocket message goes to all targets. Replies can interleave.

Configure the dedicated WSS listener on the server with https_terminate. Register and assign its TCP port, upload an ML-DSA-87 certificate chain and key for the domain, and create a WSS entry and path. The client must trust the certificate's CA and support ML-DSA-87 and MLKEM1024 and TLS_AES_256_GCM_SHA384.

Private TCP and UDP access ​

  1. Add a second client and start it with its certificate ZIP and client key. Give each client on the same host its own data_path and log_path. Start a client · Data and log directories
  2. Under Resources → Tunnel Mappings, create a visitor mapping named Internal web. Set the mapping path to /internal-web, select TCP ingress and Private relay (STCP), and choose the second client as source client A. Set A's listen IP to 127.0.0.1 and its port to 28080. Select the client running the Python HTTP service as target client B, with TCP and 127.0.0.1:8000 as the target.
  3. Leave Gateway business endpoint blank under Gateway connection settings to use the endpoint advertised by the server. To override it, enter an endpoint A can reach, such as wss://api.tunnel.example.com:9653. A binds and reserves the listener before the mapping is saved. If the port is occupied, the save is rejected. A must be online, connected directly to the gateway, and able to reserve ports. After saving, run this command on A.
sh
curl --fail --noproxy '*' http://127.0.0.1:28080/

To reach A from its LAN, set the listen IP to A's LAN address. Add further source clients under Details → Access Grants. The visitor gateway endpoint also accepts tls:// over TCP and quic:// over UDP. An STCP application still connects to the visitor over TCP when the visitor uses quic:// to reach the gateway. For private UDP, choose UDP ingress and Private relay (SUDP). Gateway and private relays let you select the target protocol independently. Web targets use the request formats and header rules above, with source information obtained by A. Prefer direct (XTCP) uses TCP for both ingress and target. XTCP direct connections

QUIC work relay ​

Add a QUIC endpoint to the provider's app.yml and keep the existing work relay. Open 9652/UDP on the server and restart the client. Select QUIC under Work relay when creating or editing the mapping.

yaml
relay_endpoint: wss://api.tunnel.example.com:9652
relay_endpoints:
  - quic://api.tunnel.example.com:9652

KCP work relay ​

The server listens on 0.0.0.0:9654 by default. Allow 9654/UDP from the provider. When you set the control address to tls://api.tunnel.example.com:9651 and omit relay settings, the client prefers kcp://api.tunnel.example.com:9654. If KCP is unavailable, the client can use an authenticated relay on 9652/TCP. A mapping that explicitly selects KCP uses that protocol. For a custom port, set kcp_relay on the server and specify kcp://host:port on the client.

TCPMUX routing ​

TCPMUX lets multiple TCP services share one HTTP CONNECT entry point and routes each request by the target name. Match Basic username (optional) further routes requests by the username in Proxy-Authorization. Leave it blank for the default route. To verify passwords, configure Basic authentication with the same username.

  1. Register and assign 62501/TCP under Resources → Port Resources. Register app.example.test under Domains and Certificates for use as the CONNECT target name.
  2. In Mappings → Route Tunnels → Business Routes, select New Route. Choose TCPMUX, select 62501 from the pool, and choose app.example.test as the CONNECT target name. Select the provider and set the target to 127.0.0.1:8000.
  3. Enable the route, leave Forward CONNECT handshake to the target off, and run the following command on the gateway host.
sh
curl --fail --noproxy "" --proxytunnel --proxy http://127.0.0.1:62501 http://app.example.test/

MQTT access ​

The server and client connect to the same broker over MQTT 5 and TLS 1.3, using MLKEM1024 and TLS_AES_256_GCM_SHA384 and validating the broker's ML-DSA-87 certificate chain. For OpenSSL-backed Mosquitto, load the broker process's TLS configuration through OPENSSL_CONF and set Groups = MLKEM1024, Ciphersuites = TLS_AES_256_GCM_SHA384, and SignatureAlgorithms = mldsa87. A separate end-to-end mutual TLS 1.3 session handles Tunnel device authentication and protects application data. When one side closes its send direction normally, the MQTT transport continues forwarding in the opposite direction and waits within the close deadline for the broker to acknowledge the final publishes.

  1. Create server and independent client accounts on the broker. As a system administrator, open Resources → MQTT Relays. Add and enable a relay with the broker address, TLS port, topic namespace, and Tunnel TLS server name. Use a DNS name or IP address from the Tunnel server certificate for the Tunnel TLS server name.
  2. Enter the server’s broker credentials. Under Independent client credentials, add the client account with a reference such as device-a. Import the ML-DSA-87 broker CA in PEM format before enabling the relay. If the broker requires mutual TLS, provide an ML-DSA-87 client certificate chain and matching unencrypted PKCS #8 key for each relevant identity.
  3. In Clients → List, add a client using MQTT Bridge, then select the enabled relay and device-a. To use Shared authentication, first allow clients to share the server credentials in the relay settings.
  4. Download the client certificate ZIP and use mqtt-topics.txt to configure topic ACLs for both sides. Extract the ZIP, restrict access to its private keys and password files, then run client --config app.yml run from the extracted directory.
  5. When the client comes online, register port 8989 and create a native mapping from 8989/TCP to 192.168.1.10:22/TCP on the MQTT client. Select MQTT bridge or Inherit provider (MQTT bridge) as the work relay. Leave source forwarding disabled for a direct OpenSSH target.

For routes with multiple backends, select MQTT explicitly when every target client supports it. Use Inherit each provider when the targets mix direct and MQTT access. MQTT relay management

After rotating the Tunnel CA, obtain the new public issuer.pem from the active signing chain and distribute it to MQTT clients through a trusted channel. Replace tunnel-ca.pem, keeping the client certificate, private key, and data directory, then reload or restart the client. Certificate rotation

Register a relay through startup configuration ​

To seed the relay from a file, set mqtt_profiles: mqtt-profiles.yml on the server. Create the broker accounts and save passwords of at least 20 bytes. An enabled relay requires ca_pem to point to the ML-DSA-87 broker CA. Set enabled: false to disable the relay and omit ca_pem. The server validates any supplied CA file. Resolve CA and password paths relative to mqtt-profiles.yml. The server imports the file when it initializes relay settings and reads the database on later starts. Use the console workflow above for a broker that requires client certificates.

yaml
production:
  label: Production MQTT
  owner: admin
  namespace: prod-a
  host: broker.example.com
  server_name: api.tunnel.example.com
  ca_pem: broker-ca.pem
  server:
    username: tunnel-server
    password_file: secrets/mqtt-server
  clients:
    device-a:
      username: tunnel-device-a
      password_file: secrets/mqtt-device-a

Set owner to the account that owns the relay. To seed the relay in a Compose deployment, put the configuration, CA, and password files in the server deployment's ./mqtt directory. Add the read-only mount ./mqtt:/app/mqtt:ro and set TUNNEL_MQTT_PROFILES: /app/mqtt/mqtt-profiles.yml.

Run the MQTT client with Compose ​

Extract the MQTT ZIP from the console to ./mqtt-client in the client deployment directory. Replace RELEASE_TAG with the image tag. When the broker requires mutual TLS, also set mqtt-client/mqtt-client.key to mode 0600.

sh
sudo install -d -m 0700 -o 10001 -g 10001 data
sudo chown -R 10001:10001 ./mqtt-client
sudo chmod 0700 ./mqtt-client
sudo chmod 0600 ./mqtt-client/client.key ./mqtt-client/mqtt-password
yaml
services:
  client:
    image: xigexb/xigexb-tunnelc:RELEASE_TAG
    command: ["--config", "/app/mqtt-client/app.yml", "run"]
    network_mode: host
    restart: always
    cap_drop:
      - ALL
    security_opt:
      - "no-new-privileges:true"
    volumes:
      - ./mqtt-client:/app/mqtt-client:ro
      - ./data:/app/data

Save as docker-compose.yml and run docker compose up -d client. Check the client with docker compose exec -T client /app/xtc --config /app/mqtt-client/app.yml status.

Publish a directory with the static-file plugin ​

Put index.html in plugin-assets/files/site under the provider's data directory. Open Details → Plugins and Virtual Networking and add the entry to plugins. Once the client applies it, point a native TCP mapping or Web Reverse Proxy route at 127.0.0.1:18090.

json
{
  "plugins": [
    {
      "type": "static_file",
      "listen": "127.0.0.1:18090",
      "local_path": "site",
      "directory_listing": false
    }
  ]
}

Plugins listen on nonzero loopback ports. File paths are relative to plugin-assets/files, password and TLS material to plugin-assets/secrets, and Unix sockets to plugin-assets/sockets. Plugin TLS termination uses ML-DSA-87 and MLKEM1024 and TLS_AES_256_GCM_SHA384. Managed virtual networking

Restrict public access by source ​

  1. Open Security → GeoX Data and confirm the data is ready.
  2. Create a group under Security → Security Groups with Deny as the default action. Add an allow rule with GEOIP,CN as the source. To deny a specific subnet first, add a CIDR deny rule with a lower priority number.
  3. Bind the group to the native mapping or route. In the group preview, enter a source IP, protocol, and port to check which rule applies.

Rules with the same priority follow list order. If GeoX cannot classify a source, evaluation continues with later rules or the default action. Security groups · GeoX data

OpenSSH reverse TCP ​

Generate a gateway host key and a device key. Leave the host key passphrase empty and restrict access to the private key. Paste the complete line of the device's public key into the configuration.

sh
ssh-keygen -t ed25519 -f ./ssh_host_ed25519_key
ssh-keygen -t ed25519 -f ./edge_ed25519
yaml
host_key: ./ssh_host_ed25519_key
users:
  - username: edge
    public_keys:
      - "ssh-ed25519 REPLACE_WITH_EDGE_PUBLIC_KEY"
    listen:
      - "127.0.0.1:22080"

Save as ssh-gateway.yml and start the SSH gateway.

sh
server serve-ssh-gateway --listen 127.0.0.1:7022 --config ./ssh-gateway.yml

On the first connection, check the host fingerprint against ssh-keygen -lf ./ssh_host_ed25519_key.pub on the gateway. With SSH connected, access the forwarded port from the gateway host.

sh
ssh -i ./edge_ed25519 -N -o ExitOnForwardFailure=yes -R 127.0.0.1:22080:127.0.0.1:8000 -p 7022 edge@127.0.0.1
sh
curl --fail --noproxy '*' http://127.0.0.1:22080/

PostgreSQL and production listeners ​

Set database: postgres or database: mysql and supply the connection URL through TUNNEL_DATABASE_URL. Create a dedicated empty database and an account that can create tables and write data. Tunnel creates the complete current schema on first start. Compose deployment · Backup and controlled recovery