Sign inSign up

elebree/webhop-cli

By elebree

•Updated 5 days ago

Exposes any local HTTP server through your own WebHop gateway

Image
0

320

elebree/webhop-cli repository overview

⁠webhop

Expose any local HTTP server through your own WebHop⁠ gateway, much like ngrok http. The local server needs no WebHop code and doesn't have to be .NET. webhop opens no listening port: it only connects out to the gateway and to your local server.

You need a running gateway; see WebHop.Gateway⁠.

⁠Install

dotnet tool install -g webhop

Or download the standalone Native AOT binary, which runs without .NET, and unpack it somewhere on your PATH:

Windows x64 Windows arm64 Linux x64 Linux arm64 macOS arm64

On macOS, a binary downloaded with a browser is quarantined; clear that with xattr -d com.apple.quarantine webhop.

⁠Usage

webhop config add-gateway-url https://my-gateway.example.com/
webhop config add-authtoken <token>
webhop http 5000
WebHop                                                (Ctrl+C to quit)

Session Status                online
Version                       2.0.0
Origin Id                     5c11642ef14844fb98e6cfcb5ac6ea99
Tunnels                       10/10 open
Forwarding                    https://my-gateway.example.com -> http://localhost:5000

Connections                   ttl     opn     p50       p90
                              6       0       17 ms     46 ms

HTTP Requests
-------------
01:51:47  GET     /slow                                     200 OK                        1,5 s
01:51:45  GET     /missing?x=1                              404 Not Found                 17 ms

⁠Commands

The commands and flags follow ngrok's.

CommandWhat it does
webhop http 5000Forward to http://localhost:5000; also accepts localhost:5000 or a full URL such as https://localhost:7001
webhop config add-gateway-url <url>Save the gateway to connect to
webhop config add-authtoken <token>Save the gateway's auth token
webhop config check / config editShow or edit the saved settings
webhop versionShow the version
webhop help [command], webhop <command> --helpUsage and all flags
Flag for webhop httpMeaning
--urlGateway URL, which is also the public URL. Default: WEBHOP_URL, then the saved gateway
--authtokenThe gateway's auth token. Default: WEBHOP_AUTHTOKEN, then the saved auth token
--host-header=rewriteSend Host: localhost:<port>, for dev servers that reject other hosts (Vite, webpack dev server)
--log=stdout|stderr|<file>stdout/stderr print log lines instead of the live screen (also used when output is redirected); a file path keeps the screen and writes the log to the file
--log-level=debug|info|warn|error|critHow much to log (default info)
--log-format=term|jsonLog line format
--configUse another config file
--connectionsTunnels to keep open (WebHop-specific)

Flags can come in any order, before or after the command, as --flag value or --flag=value.

The settings are saved in %APPDATA%\webhop\webhop.json on Windows and ~/.config/webhop/webhop.json elsewhere.

⁠Docker

The elebree/webhop-cli image on Docker Hub (also ghcr.io/elebree/webhop-cli) runs webhop on linux/amd64 and linux/arm64, for tunnels that run unattended next to other containers. Each release is tagged with its version (2.1.0), its minor version (2.1) and latest; edge is the newest build of main.

Pass the gateway and the auth token as environment variables. Inside a container localhost is the container itself, so reach a server on the host as host.docker.internal (on Linux, add --add-host=host.docker.internal:host-gateway):

docker run --rm -it -e WEBHOP_URL=https://my-gateway.example.com/ -e WEBHOP_AUTHTOKEN=<token> elebree/webhop-cli http http://host.docker.internal:5000

-it shows the live screen; without it, webhop prints log lines. In Docker Compose, it exposes another service of the stack by its service name:

services:
  app:
    image: my-app
  tunnel:
    image: elebree/webhop-cli
    command: http http://app:8080
    environment:
      WEBHOP_URL: https://my-gateway.example.com/
      WEBHOP_AUTHTOKEN: ${WEBHOP_AUTHTOKEN}
    restart: unless-stopped

⁠Notes

  • The local server sees the public Host header and X-Forwarded-For/Proto/Host.
  • Self-signed certificates are accepted for local https targets.
  • If the local server isn't running, visitors get a 502 page that says so.
  • From a clone of the repository, run it with dotnet run --project WebHop.CLI -- http 5000.

⁠More

https://github.com/elebree/WebHop⁠

Tag summary

Content type

Image

Digest

sha256:6fa309921…

Size

12.6 MB

Last updated

8 days ago

docker pull elebree/webhop-cli