Hacker News new | ask | show | jobs
by nevi-me 3336 days ago
If you don't have a static IP that's internet-accessible, and that which you can arbitrarily point your domain to, how would you go about doing this?

Some, if not most, services won't allow you to redirect cold to an IP address, they want some domain of sorts. There are alternatives, but I think "setup a proper dev environment" alone misses the point of what ngrok does.

The 'easiest' alternative I've tried before was to VPN into my Linux box to get a static internal IP, use a spare domain for the webhook then internally redirect the webhook traffic to my local machine. In the end I'm achieving what ngrok is doing (and none of it involves setting up a proper dev environment, cos I would already have one anyways), but I'd like to hear of better alternatives :)

2 comments

i tend to fire up reverse port forwarding with ssh + special subdomain + ask nginx to proxy to the reverse-forwarded port on that special subdomain to resolve this, obviously you'd still need a static and public ip somewhere, but any ssh-accessible host will now do.

it's a bit of setup, but works quite well once set. does _not_ provide the features ngrok does of replay, etc, but at least it's 100% your own infrastructure.

edit: to clarify: no reason why it should be a special subdomain, i just use beta.mywebsite.com, just something that belongs to you and is globally dns resolvable, could be mytestdomain.com for your use. you can skip nginx if you don't mind binding to port 80 directly (i.e: no webserver already exists on that machine)

> but at least it's 100% your own infrastructure

This is probably a good thing for security. But for the use case of development against third party services, it seems like an unnecessary constraint.

I do exactly this. I also have it set up with let's encrypt so that the Webhooks are encrypted.

Locally, I also mirror the LE keys and add a hosts file entry for the test domain to localhost.

This means I can test locally with proper ssl certs.

+1 original reason i did it was so i can have the LE cert to test a slack bot i was developing (they require webhooks have SSL to do that)
Surely you've heard of dynamic DNS?
Ngrok also works without port forwarding through a router
nip.io and xip.io even could be used, but that won't help if there's no static ip.

of course you can portforward your ip via vpn or ssh tunnel. And that's would be the exact equivalent of ngrok, but with way more time and frustration to set it up.

oups, meant "routable" instead of "static"
Surely you've noticed this:

> don't have a static IP that's internet-accessible

I am one of those people :) I don't pay my ISP extra for a "real" IP address, so I have literally no way to receive incoming connections from the internet into my home network, it's all behind their NAT.

You don't need a static IP.
You do need a public IP.
And you probably have one at the office, or you surely do at your hosting service or ... But if you really don't then a VPS with unlimited data is cheaper than ngrok basic plan - and a lot more useful.
The whole reason why I VPN into a box is that it has a static and publicly accessible IP address. Interesting that all the other alternatives proposed basically do the same thing. Point to an URL you control, and proxy traffic to where you want.