#web-server #local #url #expose #wormhole #internet #public

bin+lib wormhole-tunnel

使用公共URL将本地Web服务器暴露给互联网

6 个版本

0.1.5 2020年4月25日
0.1.4 2020年4月19日

HTTP服务器 中排名第 896

MIT 许可证

51KB
1K SLoC

BuildRelease crate DockerHub crate

wormhole

wormhole 允许您通过公共URL暴露本地运行的Web服务器。用Rust编写。完全使用tokio上的async-io构建。

  1. 安装Wormhole
  2. 使用说明
  3. 自行托管

安装

Brew (macOS)

brew install agrinman/tap/wormhole

Cargo

cargo install wormhole-tunnel

或者 在此处下载目标操作系统版本: wormhole/releases

使用方法

快速开始

 wormhole start -p 8000

上述命令打开wormhole并将流量隧道传输到 localhost:8000

更多选项

 wormhole start -h
wormhole-start 0.1.4
Start the wormhole

USAGE:
    wormhole start [OPTIONS] --port <port>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -k, --key <key>                 Sets an API authentication key to use for this wormhole
    -p, --port <port>               Sets the port to forward incoming tunnel traffic to on localhost
    -s, --subdomain <sub-domain>    Specify a sub-domain for this wormhole

自行托管

  1. 为musl目标编译服务器。有关使用Docker轻松完成此操作的方法,请参阅 musl_build.sh
  2. 有关运行该服务器的简单alpine基于的镜像,请参阅 Dockerfile
  3. 将镜像部署到您想要的位置。

本地测试

# Run the Server: xpects TCP traffic on 8080 and control websockets on 5000
ALLOWED_HOSTS="localhost" ALLOW_UNKNOWN_CLIENTS=1 cargo run --bin wormhole_server

# Run a local wormhole talking to your local wormhole_server
WORMHOLE_HOST="localhost" WORMHOLE_PORT=5000 TLS_OFF=1 cargo run --bin wormhole -- start -p 8000

# Test it out!
# Remember 8080 is our local wormhole_server TCP server
curl -H '<subdomain>.localhost' "https://127.0.0.1:8080/some_path?with=somequery"

服务器环境变量

  • ALLOWED_HOSTS: 允许转发哪些主机名后缀
  • SECRET_KEY: 用于限制对wormhole服务器的访问的认证密钥
  • ALLOW_UNKNOWN_CLIENTS: 一个布尔标志,如果设置,则允许未知(无认证)客户端使用wormhole。注意,未知客户端不允许通过 -s 选择子域名。

注意事项

此实现不支持多个运行的服务器(即集中式协调)。因此,如果您部署多个服务器实例,只有在客户端连接到与远程TCP流相同的实例时,它才会正常工作。

依赖项

~24–38MB
~624K SLoC