· NGSRV Team
How to share a Ruby on Rails dev server online
You finished a feature branch and someone off your machine needs to click through it. Deploying a staging build works, but it is slow. Running bin/rails server and tunneling it is faster.
Asset pipeline and Action Cable both tunnel fine over HTTP.
Steps
# 1. Start Ruby on Rails
bin/rails server
# 2. In another terminal, tunnel the port
ngsrv http 3000
Check config/environments/development.rb if the dev server complains about the hostname.
If the dev server blocks the public host
Rails 6+ checks hosts. Add the ngsrv hostname to config.hosts in development.rb if requests get blocked.
Reserve a URL that does not change
ngsrv http 3000 --subdomain rails-preview
Hand that link to QA or a client. Same URL after you restart the tunnel.
Declarative config for teams
Check a ngsrv.yml into the repo so everyone runs the same tunnel names:
tunnels:
- name: rails
port: 3000
subdomain: rails-preview
Then ngsrv run.