public
Description: Config files to easily manage multiple Merb/Rails apps behind Nginx
Homepage:
Clone URL: git://github.com/glasner/conf-nginx.git
conf-nginx / app_examples / merb.conf
100644 48 lines (39 sloc) 1.089 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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;
    }
  }
 
}