3 ms·
Making a local web server public with localtunnel
- callmeed 16y agoThis looks kinda cool, but when I need to expose my local dev environment (for example, for testing callbacks/hooks), I always just forward a port on my router and use the IP address.
- lftl 16y agoThat definitely makes sense when you're at home or in the office, but I've recently started working off my laptop a lot more, and this is helpful when I'm at a cafe or a clients site and I don't have any access to the router and need to give someone access.
- andrewtj 16y agoBonjour and Wide-area Bonjour (aka DNS-SD) are great for this kind of thing. If you set your dev server to advertise itself users on the local network can just open Safari or Firefox (with an extension) and pick the dev site from a list of services. Wide-area Bonjour enables the same functionality over the internet with a few caveats — you've got to do some additional configuration and only Windows and OS X machines can register services (Avahi can only browse in wide-area domains). That said, you can still take advantage of WAB handling the port-forward and DNS record creation and just pass someone the appropriate URL to access the service.
- paulgerhardt 16y agothe ssh (or in this case autossh) oneliner for this would be something like: autossh -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 20080:localhost:80 -R 20022:localhost:22 [USER]@[REMOTE-HOST] where 20022 is the port you can remotely ssh into from anywhere, and 20080 would be the http port on a remote system publicly visible that you have access to. Autossh will respawn failed connections (say the internet connection goes out) but will fail silently with "-q" (say you haven't authorized the RSA keys yet.) I think this will work for ssh too if you drop the "-M" flag. You'll probably need keys, and it would be a good idea to make a specific user with no shell access, and restrict the ssh keys as the article mentions...
- l4u 16y agoi have been using ssh and port forwarding to achieve this. lcoaltunnel seems to be a good alternative, but sadly i cannot access that site now