# Merb Virtual Host # save this file in your app's config directory as nginx.conf # replace app_name w/ your app's name # replace app.com w/ your app's domain upstream app_name { # replace 4000-4002 w/ the ports merb will be on server 127.0.0.1:4000; server 127.0.0.1:4001; server 127.0.0.1:4002; } server { listen 80; server_name app.com; # write app specific log # make sure you create this file in your log directory before running behind nginx access_log /www/apps/app_name/shared/log/nginx.log main; # let nginx serve static files directly # images location ^~/images { root /www/apps/app_name/current/public; } # javascript location ^~/javascripts { root /www/apps/app_name/current/public; } # css location ^~/stylesheets { root /www/apps/app_name/current/public; } # Push all other requests to Merb location / { # needed to forward user's IP address to merb proxy_set_header X-Real-IP $remote_addr; if (!-f $request_filename) { proxy_pass http://app_name; break; } } }