Hacker News·4 min read·hard

Self-hosted HTTP tunnels with SSH and Nginx

R
renehsz
Self-hosted HTTP tunnels with SSH and Nginx
✦AI Summary

This article provides a technical guide on creating a self-hosted HTTP tunnel using only OpenSSH and Nginx. It explains how to route traffic from a local development environment to a public URL by leveraging dynamic port allocation and wildcard DNS configurations.

Why it matters

It offers a cost-effective, privacy-focused alternative to commercial tunneling services like ngrok for developers needing to share local work.

✦Dive DeeperCreate a free account to unlock

A friend wants to proofread your work-in-progress blog post, but its preview only runs on localhost:8080 . Several tools can help. Some run as a commercial service, like ngrok or Cloudflare Quick Tunnels . Some are self-hostable but require a specific client, like frp or localtunnel . Some only require a plain SSH client but rely on a specific SSH server, like sish . Let’s implement a self-hosted solution with only OpenSSH and nginx !

$ ssh -R 0 :localhost:8080 http-over-ssh Allocated port 41535 for remote forward to localhost:8080 https://6J3jK1WmB15c6WmjW_X-Wg--1789928654@p41535.ssh.luffy.cx/ Basic setup # First, we forward connections from a port on a remote server to your local service:

$ ssh -N -R 0 :localhost:8080 web02.luffy.cx Allocated port 41535 for remote forward to localhost:8080 When you specify 0 as the remote port, the server allocates a free port. Then, we configure nginx to proxy requests from https://p41535.ssh.luffy.cx to http://127.0.0.1:41535 :

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technologydesign
✦

Get smarter about the news

Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.

Create free account

Already have an account? Sign in