Hacker News new | ask | show | jobs
by mcgwiz 2705 days ago
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.