lib/capistrano/templates/nginx_conf.erb in capistrano3-puma-1.2.1 vs lib/capistrano/templates/nginx_conf.erb in capistrano3-puma-2.0.0
- old
+ new
@@ -1,52 +1,51 @@
upstream puma_<%= fetch(:nginx_config_name) %> { <%
- flags = 'fail_timeout=0'
@backends = [fetch(:puma_bind)].flatten.map do |m|
etype, address = /(tcp|unix|ssl):\/{1,2}(.+)/.match(m).captures
- if etype =='unix'
+ if etype == 'unix'
"server #{etype}:#{address} #{fetch(:nginx_socket_flags)};"
else
"server #{address.gsub(/0\.0\.0\.0(.+)/, "127.0.0.1\\1")} #{fetch(:nginx_http_flags)};"
end
end
-%><% @backends.each do |server| %>
+%><% @backends.each do |server| %>
<%= server %><% end %>
}
-<% if fetch(:nginx_use_ssl) %>
+<% if fetch(:nginx_use_ssl) -%>
server {
listen 80;
+ server_name <%= fetch(:nginx_server_name) %>;
rewrite ^(.*) https://$host$1 permanent;
}
-<% end %>
+<% end -%>
server {
-<% if fetch(:nginx_use_ssl) %>
+<% if fetch(:nginx_use_ssl) -%>
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/<%= fetch(:nginx_config_name) %>.crt;
ssl_certificate_key /etc/ssl/private/<%= fetch(:nginx_config_name) %>.key;
-<% else %>
+<% else -%>
listen 80;
-<% end %>
+<% end -%>
+ server_name <%= fetch(:nginx_server_name) %>;
+ root <%= current_path %>/public;
+ try_files $uri/index.html $uri @puma_<%= fetch(:nginx_config_name) %>;
client_max_body_size 4G;
keepalive_timeout 10;
error_page 500 502 504 /500.html;
error_page 503 @503;
- server_name <%= fetch(:nginx_server_name) %>;
- root <%= current_path %>/public;
- try_files $uri/index.html $uri @puma_<%= fetch(:nginx_config_name) %>;
-
location @puma_<%= fetch(:nginx_config_name) %> {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
-<% if fetch(:nginx_use_ssl) %>
+<% if fetch(:nginx_use_ssl) -%>
proxy_set_header X-Forwarded-Proto https;
-<% end %>
+<% end -%>
proxy_pass http://puma_<%= fetch(:nginx_config_name) %>;
# limit_req zone=one;
access_log <%= shared_path %>/log/nginx.access.log;
error_log <%= shared_path %>/log/nginx.error.log;
}
@@ -77,11 +76,7 @@
return 405;
}
if (-f $document_root/system/maintenance.html) {
return 503;
- }
-
- location ~ \.(php|html)$ {
- return 405;
}
}