|
cca59da1
»
|
gabriel |
2008-04-29 |
adding merb support |
1 |
# |
| |
2 |
# Nginx virtual host conf |
| |
3 |
# |
| |
4 |
# * Uses cache directory configured for public/cache |
| |
5 |
# * Re-writes url for iphone user agent to /iphone (so as not to conflict with cache) |
| |
6 |
# * TODO-gabe: Same for mobile user agents |
| |
7 |
# * Redirects domain.com to www.domain.com (IMO should be the other way around; www is deprecated) |
| |
8 |
# |
| |
9 |
|
| |
10 |
upstream <%= nginx_upstream_name %> { |
| |
11 |
<% nginx_upstream_ports.each do |port| %> |
| |
12 |
server 127.0.0.1:<%= port %>; |
| |
13 |
<% end %> |
| |
14 |
} |
| |
15 |
|
| |
16 |
server { |
| |
17 |
# port to listen on. Can also be set to an IP:PORT. |
| |
18 |
listen 80; |
| |
19 |
|
| |
20 |
# Set the max size for file uploads to 50Mb |
| |
21 |
client_max_body_size 50M; |
| |
22 |
|
| |
23 |
<% unless domain_name.blank? or domain_name == "localhost" %> |
| |
24 |
# sets the domain[s] that this vhost server requests for |
| |
25 |
server_name www.<%= domain_name %>; |
| |
26 |
<% end %> |
| |
27 |
|
| |
28 |
# doc root |
| |
29 |
root <%= public_path %>; |
| |
30 |
|
| |
31 |
# vhost specific access log |
| |
32 |
access_log <%= shared_path %>/log/nginx.<%= application %>.access.log main; |
| |
33 |
|
| |
34 |
# this rewrites all the requests to the maintenance.html |
| |
35 |
# page if it exists in the doc root. This is for capistrano's |
| |
36 |
# disable web task |
| |
37 |
if (-f $document_root/system/maintenance.html) { |
| |
38 |
rewrite ^(.*)$ /system/maintenance.html last; |
| |
39 |
break; |
| |
40 |
} |
| |
41 |
|
| |
42 |
location / { |
| |
43 |
# Uncomment to allow server side includes so nginx can |
| |
44 |
# post-process Rails content |
| |
45 |
## ssi on; |
| |
46 |
|
| |
47 |
proxy_set_header X-Real-IP $remote_addr; |
| |
48 |
|
| |
49 |
# needed for HTTPS |
| |
50 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| |
51 |
proxy_set_header Host $http_host; |
| |
52 |
proxy_redirect false; |
| |
53 |
proxy_max_temp_file_size 0; |
| |
54 |
|
| |
55 |
# For iphone unique url |
| |
56 |
if ($http_user_agent ~* "(iPhone|iPod)") { |
| |
57 |
rewrite ^/$ /iphone break; |
|
61eb21e3
»
|
gabriel |
2008-05-05 |
Fixes for cap 2.3 and nginx... |
58 |
proxy_pass http://<%= nginx_upstream_name %>; |
|
cca59da1
»
|
gabriel |
2008-04-29 |
adding merb support |
59 |
break; |
| |
60 |
} |
| |
61 |
|
| |
62 |
if (-f $request_filename) { |
| |
63 |
break; |
| |
64 |
} |
| |
65 |
|
| |
66 |
if (-f $document_root/cache/$uri/index.html) { |
| |
67 |
rewrite (.*) /cache/$1/index.html break; |
| |
68 |
} |
| |
69 |
|
| |
70 |
if (-f $document_root/cache/$uri.html) { |
| |
71 |
rewrite (.*) /cache/$1.html break; |
| |
72 |
} |
| |
73 |
|
| |
74 |
if (-f $document_root/cache/$uri) { |
| |
75 |
rewrite (.*) /cache/$1 break; |
| |
76 |
} |
| |
77 |
|
| |
78 |
if (!-f $request_filename) { |
|
61eb21e3
»
|
gabriel |
2008-05-05 |
Fixes for cap 2.3 and nginx... |
79 |
proxy_pass http://<%= nginx_upstream_name %>; |
|
cca59da1
»
|
gabriel |
2008-04-29 |
adding merb support |
80 |
break; |
| |
81 |
} |
| |
82 |
} |
| |
83 |
|
| |
84 |
#error_page 404 /404.html; |
| |
85 |
|
| |
86 |
# redirect server error pages to the static page /50x.html |
| |
87 |
# |
| |
88 |
error_page 500 502 503 504 /500.html; |
| |
89 |
location = /500.html { |
| |
90 |
root <%= public_path %>; |
| |
91 |
} |
| |
92 |
} |
| |
93 |
|
| |
94 |
<% unless domain_name.blank? or domain_name == "localhost" %> |
| |
95 |
server { |
| |
96 |
server_name <%= domain_name %>; |
| |
97 |
rewrite ^/(.*) http://www.<%= domain_name %>/$1 permanent; |
| |
98 |
} |
| |
99 |
<% end %> |