Hacker News new | ask | show | jobs
by malaya_zemlya 2705 days ago
If you don't want to install any third-party apps, you can do much the same by spinning up an AWS box and using SSH remote port forwarding

   ssh -NT -R 0:localhost:80 youraccount@yourbox.amazonaws.com
I also do an extra step and put an nginx proxy in front to translate hostnames into correct port numbers, but that's optional.
1 comments

Same, with Apache. We leave our reverse proxy up 24/7. Relevant Apache config:

    RewriteEngine on

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteCond %{HTTP_HOST} ^([^\.]*).*$ [NC]
    RewriteRule /(.*) ws://localhost:%1/$1 [P,L]

    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteCond %{HTTP_HOST} ^([^\.]*).*$ [NC]
    RewriteRule /(.*) http://localhost:%1/$1 [P,L]

    RewriteCond %{HTTP_HOST} ^([^\.]*).*$ [NC]
    RewriteRule ^ - [E=TUNNEL_PORT:$1]
    ProxyPassInterpolateEnv On
    ProxyPassReverse "/" "http://localhost:${TUNNEL_PORT}/" interpolate
This reverse proxies something like https://12345.example.com to http://localhost:12345, which is forwarded back to the dev machine (typically port 80 or 3000). When a local server is spun up, our tooling automatically sets up the remote port forwarding and appropriately configures the local instance based on an environment variable. For a pre-seed startup, this results in considerable cost savings w.r.t. ngrok's pricing.