Skip to content

Instantly share code, notes, and snippets.

@tommyvn
Last active June 26, 2023 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyvn/4aad720deb4d904be00ddd065ef05e38 to your computer and use it in GitHub Desktop.
Save tommyvn/4aad720deb4d904be00ddd065ef05e38 to your computer and use it in GitHub Desktop.
tunneling arbitrary TCP protocols like ssh or postgresql over localhost.run custom domains
  1. instal stunnel from your package manager. This allows you to wrap any TCP protocol (ssh, postgresql, mysql) in TLS.

  2. download the stunnel.conf from this gist and replace the example.com host with your custom domain (also in the ssh command below).

  3. run stunnel stunnel.conf in a terminal

  4. connect your localhost.run tunnel on port 80 to your backend service.

    ssh -R example.com:80:localhost:5432 plan@localhost.run connects a tunnel to a local postgres on port 5432, change the port for other services

  5. connect your client to port 9999 (or what ever port you specified in stunnel.conf), for eg:.

    • psql postgresql://localhost:9999/dbname
    • mysql -h localhost -P9999
    • ssh localhost -p 9999
foreground = yes
pid = ./stunnel.pid
[lhr]
client = yes
accept = localhost:9999
connect = example.com:443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment