Last active
September 6, 2016 11:23
-
-
Save piotrze/5e67fd96e621a6d10aeb to your computer and use it in GitHub Desktop.
Setup CORS on engineyard for font files(fontawesome)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nginx_cors/recipes/default.rb | |
#create new directory in cookbooks/ in your ey-cloud-recipes repository | |
#upload recipie, apply and restart nginx on all servers | |
# | |
# Cookbook Name:: nginx_cors | |
# Recipe:: default | |
# | |
if ['app_master', 'app', 'solo'].include?(node[:instance_role]) | |
node[:applications].each do |app, data| | |
template "/tmp/location.block" do | |
source 'location.block.erb' | |
end | |
execute "add header to conf" do | |
command "sed -i '/error_log \\/var\\/log\\/engineyard\\/nginx\\/#{app}.error.log notice;/r /tmp/location.block' /etc/nginx/servers/#{app}.conf" | |
not_if "grep -q Access-Control-Allow-Origin /etc/nginx/servers/#{app}.conf" | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#nginx_cors/templates/default/location.block.erb | |
location ~ ^/(assets|stylesheets)/ { | |
if ($request_filename ~ (ttf|ttc|otf|eot|woff)$) { | |
add_header Access-Control-Allow-Origin *; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the script!
after using for awhile, I added
to ensure that nginx was reloaded. It appeared on my systems that nginx was starting before the
.conf
file was updated.