This repository has been archived by the owner on Apr 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
app_nginx.conf.erb
69 lines (53 loc) · 1.99 KB
/
app_nginx.conf.erb
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<%= @custom_configuration["before_server"] %>
<% if @redirect_domain_names && @redirect_domain_names.any? %>
server {
listen <%= node['nginx']['port'] || '80' %>;
<% if @enable_ssl %>
listen 443 ssl;
<% end %>
server_name <%= @redirect_domain_names.join(' ') %>;
return 301 $scheme://<%= @domain_names.first %>$request_uri;
}
<% end %>
server {
listen <%= node['nginx']['port'] || '80' %>;
server_name <%= @domain_names.join(' ') %>;
root <%= node['rails']['applications_root'] %>/<%= @name %>/current/public;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://<%= @name %>;
<%= @custom_configuration["server_app"] %>
}
<%= "client_max_body_size #{@client_max_body_size};" if @client_max_body_size.to_i != 0 %>
<%= @custom_configuration["server_main"] %>
}
<% if @enable_ssl %>
server {
listen 443 ssl;
ssl_certificate <%= node['rails']['applications_root'] %>/<%= @name %>/shared/config/certificate.crt;
ssl_certificate_key <%= node['rails']['applications_root'] %>/<%= @name %>/shared/config/certificate.key;
server_name <%= @domain_names.join(' ') %>;
root <%= node['rails']['applications_root'] %>/<%= @name %>/current/public;
location / {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_pass http://<%= @name %>;
<%= @custom_configuration["ssl_app"] %>
}
<%= "client_max_body_size #{@client_max_body_size};" if @client_max_body_size.to_i != 0 %>
<%= @custom_configuration["ssl_main"] %>
}
<% end %>
upstream <%= @name %> {
server unix:<%= node['rails']['applications_root'] %>/<%= @name %>/shared/tmp/sockets/unicorn.sock;
<%= @custom_configuration["upstream"] %>
}
<%= @custom_configuration["after_server"] %>