glasner / conf-nginx

Config files to easily manage multiple Merb/Rails apps behind Nginx

This URL has Read+Write access

conf-nginx / app_examples / sinatra.conf
100644 33 lines (26 sloc) 0.703 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
# Sinatra Virtual Host
# create a config directory and include nginx.conf
# replace app_name w/ your app's name
# replace app.com w/ your app's domain
 
upstream app_name {
  server 127.0.0.1:4567;
}
 
server {
  listen 80;
        server_name app.com;
 
        access_log /www/apps/app_name/shared/log/nginx.log main;
  
  # Serve static lib files directly
  location ^~ /lib {
    root /www/apps/app_name/current;
  }
  
  # Push all other requests to Sinatra
  location / {
    # needed to forward user's IP address to rails
    proxy_set_header X-Real-IP $remote_addr;
 
    if (!-f $request_filename) {
      proxy_pass http://app_name;
      break;
    }
  }
 
  # need to handle error_pages
}