Dynamic Sites on Nginx With Passenger
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 directoryserver { 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