Go HTTP tunnel is a reverse tunnel based on HTTP/2. It enables you to share your localhost when you don't have a public IP.
- HTTP proxy with basic authentication
- TCP proxy
- Client auto reconnect
- Client management and eviction
- Easy to use CLI
Common use cases:
- Hosting a game server from home
- Developing webhook integrations
- Managing IoT devices
Build the latest version.
$ go get -u github.com/mmatczuk/go-http-tunnel/cmd/...
Alternatively download the latest release.
There are two executables:
tunneld- the tunnel server, to be run on publicly available host like AWS or GCE
tunnel- the tunnel client, to be run on your local machine or in your private network
To get help on the command parameters run
tunneld -h or
Tunnel requires TLS certificates for both client and server.
$ openssl req -x509 -nodes -newkey rsa:2048 -sha256 -keyout client.key -out client.crt $ openssl req -x509 -nodes -newkey rsa:2048 -sha256 -keyout server.key -out server.crt
.tunneldirectory in your project directory
- Create configuration file
- Start all tunnels
$ tunnel -config ./tunnel/tunnel.yml start-all
- Start tunnel server
$ tunneld -tlsCrt .tunneld/server.crt -tlsKey .tunneld/server.key
This will run HTTP server on port
80 and HTTPS (HTTP/2) server on port
443. If you want to use HTTPS it's recommended to get a properly signed certificate to avoid security warnings.
Run Server as a Service on Ubuntu using Systemd:
- After completing the steps above successfully, create a new file for your service (you can name it whatever you want, just replace the name below with your chosen name).
$ vim tunneld.service
- Add the following configuration to the file
[Unit] Description=Go-Http-Tunnel Service After=network.target After=network-online.target [Service] ExecStart=/path/to/your/tunneld -tlsCrt /path/to/your/folder/.tunneld/server.crt -tlsKey /path/to/your/folder/.tunneld/server.key TimeoutSec=30 Restart=on-failure RestartSec=30 [Install] WantedBy=multi-user.target
- Save and exit this file.
- Move this new file to /etc/systemd/system/
$ sudo mv tunneld.service /etc/systemd/system/
- Change the file permission to allow it to run.
$ sudo chmod u+x /etc/systemd/system/tunneld.service
- Start the new service and make sure you don't get any errors, and that your client is able to connect.
$ sudo systemctl start tunneld.service
- You can stop the service with:
$ sudo systemctl stop tunneld.service
- Finally, if you want the service to start automatically when the server is rebooted, you need to enable it.
$ sudo systemctl enable tunneld.service
There are many more options for systemd services, and this is by not means an exhaustive configuration file.
The tunnel client
tunnel requires configuration file, by default it will try reading
tunnel.yml in your current working directory. If you want to specify other file use
Sample configuration that exposes:
- host in private network for ssh connections
looks like this
server_addr: SERVER_IP:5223 tunnels: webui: proto: http addr: localhost:8080 auth: user:password host: webui.my-tunnel-host.com ssh: proto: tcp addr: 192.168.0.5:22 remote_addr: 0.0.0.0:22
server_addr: server TCP address, i.e.
tls_crt: path to client TLS certificate, default:
client.crtin the config file directory
tls_key: path to client TLS certificate key, default:
client.keyin the config file directory
root_ca: path to trusted root certificate authority pool file, if empty any server certificate is accepted
tunnels / [name]
proto: tunnel protocol,
addr: forward traffic to this local port number or network address, for
proto=httpthis can be full URL i.e.
https://machine/sub/path/?plus=params, supports URL schemes
proto=http) (optional) basic authentication credentials to enforce on tunneled requests, format
proto=http) hostname to request (requires reserved name and DNS CNAME)
proto=tcp) bind the remote TCP address
interval: how long client would wait before redialing the server if connection was lost, exponential backoff initial interval, default:
multiplier: interval multiplier if reconnect failed, default:
max_interval: maximal time client would wait before redialing the server, default:
max_time: maximal time client would try to reconnect to the server if connection was lost, set
0to never stop trying, default:
How it works
A client opens TLS connection to a server. The server accepts connections from known clients only. The client is recognized by its TLS certificate ID. The server is publicly available and proxies incoming connections to the client. Then the connection is further proxied in the client's network.
The tunnel is based HTTP/2 for speed and security. There is a single TCP connection between client and server and all the proxied connections are multiplexed using HTTP/2.
If this project help you reduce time to develop, you can give me a cup of coffee.
A GitHub star is always appreciated!
Copyright (C) 2017 Michał Matczuk
This project is distributed under the AGPL-3 license. See the LICENSE file for details. If you need an enterprice license contact me directly.