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).
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.
Configuration
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 -config flag.
server_addr: server TCP address, i.e. 54.12.12.45:5223
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, http, tcp or sni
addr: forward traffic to this local port number or network address, for proto=http this can be full URL i.e. https://machine/sub/path/?plus=params, supports URL schemes http and https
auth: (proto=http) (optional) basic authentication credentials to enforce on tunneled requests, format user:password
host: (proto=http, proto=sni) hostname to request (requires reserved name and DNS CNAME)
remote_addr: (proto=tcp) bind the remote TCP address
backoff
interval: how long client would wait before redialing the server if connection was lost, exponential backoff initial interval, default:500ms
multiplier: interval multiplier if reconnect failed, default:1.5
max_interval: maximal time client would wait before redialing the server, default:1m
max_time: maximal time client would try to reconnect to the server if connection was lost, set 0 to never stop trying, default:15m
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.
Donation
If this project help you reduce time to develop, you can give me a cup of coffee.
A GitHub star is always appreciated!
License
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.
请发表评论