Ruby on Rails dev environment on a remote server

published on 2009-12-25 in computing

A friend asks: I'm trying to install RoR on a remote server of mine, but it seems that RoR development methodology wants you to test your webpages on localhost:3000. But, obviously, since the computer is in the cloud, I can't just well pull up a webpage on the console. Is there an easy way to get development pages to show up on a web browser that's not local?

So there are a couple of options.

  • use mod_passenger w/Apache for all your environments. This requires quite a bit more work but it's the way you'd want to do it for any larger environment. Google will teach you all you want about this, but I recommend it only when your environments are mature and you are needing to scale out production.

  • Tell Apache to pass to localhost port 3000. You'd need to set up a dev hostname in DNS and point it at the server as well. It would look like this in the apache config:

<VirtualHost *:80>  
ProxyPreserveHost On  
ProxyPass /  
ProxyPassReverse /  
  • Similar as above, but if you don't want to mess with DNS, you can
    proxy based on the URL:
ProxyPass /foo  
ProxyPassReverse /foo

more on mod_proxy here:

  • Use ssh to tunnel requests from your local machine out to the server (ssh tunnel). ssh will forward the tcp packets across the pipe towards a host you specify on the other end. In this case, you'd tell it to send localhost port 3000 (on your laptop) across the pipe and out to localhost port 3000 on the server. This will only provide access for you (since it's a private tunnel).
    ssh -L 3000:

Then in your browser surf to

For speed, I'd probably do the last option to test that things are working and go up towards #1 as you get your environment more set up. #1 is the most amount of work (mod_passenger can be a PITA).

Tags: apache rails ror ruby rubyonrails sysadmin