Skip to content
elebreePublic

About

🥕 Self-hosted reverse HTTP tunnel for ASP.NET Core: debug your Azure App Service on localhost without changing its URL.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Hopper, the WebHop rabbit, peeking out of its burrow
WebHop

CI Coverage WebHop.Origin on NuGet WebHop.Gateway on NuGet webhop dotnet tool on NuGet Gateway image on Docker Hub .NET 7.0 | 8.0 | 9.0 | 10.0 MIT license

Expose a web server behind NAT or a firewall on a public URL, through a gateway you host yourself, like a self-hosted ngrok. The server opens WebSocket tunnels out to the gateway, so it needs no inbound ports, and the gateway forwards public HTTP traffic through them.

Everything HTTP passes through: streamed bodies of any size, WebSockets, server-sent events and client disconnects.

  • webhop: an ngrok-style command line tool that exposes any local HTTP server. Start here if you just want to share a local site.
  • WebHop.Origin: a library that serves your ASP.NET Core app through the gateway, in place of Kestrel's port.
  • WebHop.Gateway: the public gateway, standalone or as middleware in your ASP.NET Core app.

Quick start

1. Deploy a gateway

The gateway runs on a public host with WebSockets enabled. Pick an auth token (any long random string) and set it on the gateway as WEBHOP_AUTHTOKEN. Only servers that present it can open tunnels; public visitors don't need it.

WebHop.Gateway.Host is the ready-to-deploy gateway, with error pages for visitors and the IIS settings Azure App Service needs. Run its Docker image on your host (it serves http on port 8080; put a TLS-terminating proxy in front):

docker run -d -p 8080:8080 -e WEBHOP_AUTHTOKEN=<token> --restart unless-stopped elebree/webhop

Or publish it from a clone of this repository (needs the .NET 10 SDK) and deploy the gateway folder like any ASP.NET Core app:

git clone https://github.com/elebree/WebHop.git
dotnet publish WebHop/WebHop.Gateway.Host -c Release -o gateway

For Azure App Service, follow the step-by-step guide. To embed the gateway in your own ASP.NET Core app instead, or for reverse proxy and hosting notes, see WebHop.Gateway.

Below, https://gateway.example.com/ stands for your gateway's URL.

2a. Expose any local server with webhop

dotnet tool install -g webhop

Or download a standalone binary that runs without .NET:

Windows x64 Windows arm64 Linux x64 Linux arm64 macOS arm64

For tunnels that run unattended next to other containers, there's also a Docker image.

Point it at your gateway and forward a local port:

webhop config add-gateway-url https://gateway.example.com/
webhop config add-authtoken <token>
webhop http 5000

The site on localhost:5000 is now public at https://gateway.example.com/. All commands and flags: webhop.

2b. Or connect an ASP.NET Core app directly

dotnet add package WebHop.Origin
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseWebHop();

Start it with the gateway's auth token in WEBHOP_AUTHTOKEN, and set --urls to the gateway's URL. That is both where the app connects and where it listens for requests:

dotnet run --urls https://gateway.example.com/

The app is now public at https://gateway.example.com/. Options and configuration: WebHop.Origin.

License

MIT

About

🥕 Self-hosted reverse HTTP tunnel for ASP.NET Core: debug your Azure App Service on localhost without changing its URL.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages