-
Notifications
You must be signed in to change notification settings - Fork 82
Feature/gzip support #158
base: master
Are you sure you want to change the base?
Feature/gzip support #158
Changes from 4 commits
261663d
ab45b41
509308f
17e44b4
39a50fd
b91c7c6
be800ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,11 @@ | |
end | ||
|
||
end | ||
|
||
describe file("/etc/nginx/sites-available/intercity_sample_app.conf") do | ||
it { should be_file } | ||
|
||
its(:content) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you but a describe file("/etc/nginx/sites-available/intercity_sample_app.conf") do
it { should be_file }
context "GZip support enabled" do
its(:content) do
should match /location ~ \^\/\(assets\)\/.*gzip_static on;/m
end
end
end |
||
should match /location ~ \^\/\(assets\)\/.*gzip_static on;/m | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,7 +118,9 @@ | |
domain_names: app_info["domain_names"], | ||
redirect_domain_names: app_info["redirect_domain_names"], | ||
enable_ssl: File.exists?("#{applications_root}/#{app}/shared/config/certificate.crt"), | ||
custom_configuration: nginx_custom_configuration(app_info)) | ||
custom_configuration: nginx_custom_configuration(app_info), | ||
gzip_enabled: app_info["gzip_enabled"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess not, since app_info is an application config read from rails cookbook config. There could be more then one application per node config:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, good point. What about |
||
) | ||
notifies :reload, resources(service: "nginx") | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
location ~ ^/(assets)/ { | ||
root <%= @server_root_public_path %>; | ||
gzip_static on; | ||
expires max; | ||
add_header Cache-Control public; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpicking here, but the } is not placed correctly yet ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I've got some issues with rendering partials, the first line is always shifted 2 spaces right |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
<% server_root_public_path = "#{node['rails']['applications_root']}/#{@name}/current/public" %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be possible to set this from the recipe instead of in the template? Somehow this feels a little hacky |
||
|
||
<%= @custom_configuration["before_server"] %> | ||
|
||
server { | ||
listen <%= node['nginx']['port'] || '80' %>; | ||
server_name <%= @domain_names.join(' ') %>; | ||
root <%= node['rails']['applications_root'] %>/<%= @name %>/current/public; | ||
root <%= server_root_public_path %>; | ||
|
||
passenger_enabled on; | ||
passenger_app_env <%= @rails_env %>; | ||
|
||
<%= render '_app_nginx_location_assets.erb', variables: { server_root_public_path: server_root_public_path } if @gzip_enabled %> | ||
|
||
<%= @custom_configuration["server_main"] %> | ||
} | ||
|
||
|
@@ -23,7 +28,10 @@ server { | |
|
||
server_name <%= @domain_names.join(' ') %>; | ||
|
||
root <%= node['rails']['applications_root'] %>/<%= @name %>/current/public; | ||
root <%= server_root_public_path %>; | ||
|
||
<%= render '_app_nginx_location_assets.erb', variables: { server_root_public_path: server_root_public_path } if @gzip_enabled %> | ||
|
||
<%= @custom_configuration["ssl_main"] %> | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to have the sample default to
false
? Since people do have to perform some task on their rails apps to make this work