Self-hosted HTTP tunnels with only SSH and nginx

Self-hosted HTTP tunnels with SSH and Nginx

Self-hosted HTTP tunnels with only SSH and nginx

Vincent Bernat shows how to expose a local web service through a self-hosted tunnel using only OpenSSH and nginx. A remote port forward with ssh -R 0:localhost:8080 gets an ephemeral port, and nginx proxies a wildcard subdomain to it. Access is protected by a secure link hash in the URL, with a helper script that finds the allocated port and prints a shareable URL.

With this solution, I only rely on OpenSSH and nginx, two pieces of software already running on this server. One short command gives me a self-hosted tunnel and a URL to share.
  1. antoniomika

    A number of years ago, I created a fully open source (MIT) project called sish [0] that does just this.

    sish is a SSH server written specifically for tunneling. You get all of the benefits of SSH, but also automatic TLS, a web console of requests a tunnel has received, and various other features. You can also tunnel more than just HTTP(S). You can tunnel websockets, TCP connections, and even have internal alias connections for using ProxyJump within the tunnel. All stateless and all protected with SSH auth.

    If you’re not interested in self hosting, there’s a hosted version at tuns.sh [1] that has multi region support and a few other cool features (including UDP tunneling) as part of the pico.sh [2] membership ($2/mo). Happy to answer any questions in this space!

    [0] https://github.com/antoniomika/sish

    [1] https://tuns.sh

    [2] https://pico.sh

  2. toomim

    For this stuff, I'm most excited about https over iroh.

    - https://github.com/aflin/iroh-webproxy

    - https://github.com/n0-computer/iroh-proxy-utils

    No port forwarding. No public IP required. No special proxy to set up.

    Iroh already runs public relays. Your two computers will signal through those, and then port-knock and form a direct connection to each other, perfectly encrypted.

    We just need to define a new https:// url, like ... let's call it "irohttps://" maybe, so then you could contact my laptop with "irohttps://<hash>/path?query".

  3. aliasxneo

    This is one of the core things I've been working towards with DNTLS [1]. I love the idea of tunnels, especially for sharing between private parties. The SaaS providers (Tailscale, Cloudflare, etc.) have done a good job making it really easy on their infra, but it really blurs the line of "self-hosted" to me. Ideally we end up with solutions like this that can be run entirely without an intermediary.

    [1]: https://dntls.substack.com/p/the-new-internet

  4. jamiesonbecker

    This is wildly over-complicated and also has a bunch of footguns and security risks.

    For example, that very first NGINX section allows an attacker to direct their incoming traffic to any arbitrary listening port on localhost. They can even write a simple for loop in bash that would use curl to test all of the different ports. This also bypasses any firewall rules that you might have blocking traffic from the outside world.

    be very careful following the instructions in this article.

    Read the man page for SSH, and especially the remote forward section. https://man7.org/linux/man-pages/man1/ssh.1.html

  5. soltanov

    I like that the design composes existing tools instead of creating a new daemon, but what threat model covers leaked URLs, tunnel enumeration, forwarded credentials, and abandoned sessions?

More from this day

2026-10-04