If you are using passenger with nginx, it's possible to set nginx up in a way that allows new apps (or branches of the same app) to be deployed with no change to the server config.

Step 1

Add this config to your nginx.conf. Edit the hostname to match your server, and the root to match your deploy directory
server {
   server_name ~^([-\w]+)\.yourdomain.com;
   root /var/www/$1/current/public;
   passenger_enabled on;
}

Step 2

Deploy your rails app to /var/www/whatever/current. The app will then be available at http://whatever.yourdomain.com.

Similarly, deploying to /var/www/some-internal-app/current means the app will be available at http://some-internal-app.yourdomain.com

Notes

This technique probably isn't ideal for production sites, but for internal and or temporary sites it is quite useful. Passenger takes care of spinning up apps as they are requested, so if one app is getting lots of requests, passenger will naturally spin up more app servers for that one, potentially spinning down unused apps. Providing all apps aren't being constantly accessed, this acts as a kind of resource balancing allowing an underpowered internal server to serve a lot of apps.

blog comments powered by Disqus