{
  "id": 12155074,
  "title": "Self-hosted HTTP tunnels with SSH and Nginx",
  "url": "https://urgent.news/2026/10/04/self-hosted-http-tunnels-with-ssh-and-nginx-12155074",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-04T22:25:10.000Z",
  "source": {
    "name": "Hacker News Best",
    "slug": "hacker-news-best",
    "url": "https://vincent.bernat.ch/en/blog/2026-http-over-ssh"
  },
  "original_language": "en",
  "account": "To create a self-hosted HTTP tunnel using SSH and Nginx, a friend can provide feedback on a work-in-progress blog post. There are various tools available for this purpose, including commercial services like ngrok and Cloudflare Quick Tunnels, as well as self-hostable options such as frp and localtunnel. However, some solutions require a specific client and rely on a specific SSH server, like sish.\n\nIn this case, the focus is on implementing a self-hosted solution using only OpenSSH and nginx. The process begins by forwarding connections from a port on a remote server to a local service. When specifying 0 as the remote port, the server assigns a free port. The nginx server is then configured to proxy requests from https://p41535.ssh.luffy.cx to http://127.0.0.1:41535.\n\nTo ensure confidentiality, a secret is used as a \"key\" that keeps the content secure. This secret is used in the ngx_http_secure_link_module, which computes a hash based on a set of values, including the secret. This hash is then included in the URL as a username, along with an expiration timestamp. The client sends this username to the server using HTTP basic authentication.\n\nNginx exposes the username in the $remote_user variable, allowing the secure_link module to extract the hash and expiration timestamp. The module expects the hash and timestamp to be separated by a comma in the $remote_user variable. The module is provided with the string to hash, which includes the expiration timestamp, port, and a secret. If the hash is incorrect or missing, a 401 error is returned, and if the link has expired, a 410 error is returned.\n\nTo remove the Authorization header before forwarding the request, a few directives are added for proxying WebSocket connections. The complete configuration is provided, and a helper script is written to automate the process. The script determines the ephemeral port allocated by OpenSSH, as it is not present in environment variables.\n\nAfter setting up the server, a short command can be used to generate a self-hosted tunnel and obtain a URL to share. This solution relies solely on OpenSSH and nginx, which are already running on the server. The helper script is installed on the server, and an entry is added to the ~/.ssh/config file. With this setup, a self-hosted tunnel and a URL can be created with just one command.",
  "summary": "Article URL: https://vincent.bernat.ch/en/blog/2026-http-over-ssh Comments URL: https://news.ycombinator.com/item?id=49958569 Points: 165 # Comments: 34",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}